home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / PInterfaces / UMacApp.p < prev    next >
Encoding:
Text File  |  1990-10-25  |  168.5 KB  |  4,052 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}    { Pasmat format control line }
  2. { UMacApp.p }
  3. { Copyright © 1984-1990 by Apple Computer Inc.    All rights reserved. }
  4.  
  5. { ??? Comments that contain '???' (such as this one) indicate issues that need
  6.  to be resolved sooner or later. ???
  7.  
  8.  The MacApp® team wishes to thank MADA, Carl Nelson, Robin Mair and Jeff Alger for
  9.  generously allowing us to us the MADA MacApp 2.0 Condensed reference text freely.
  10.  This has allowed us to document a number of "historical" interfaces.  }
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := FALSE}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17. UNIT UMacApp;
  18.  
  19.     INTERFACE
  20.         {$ENDC}
  21.  
  22.         {$IFC UNDEFINED __UMacApp__}
  23.         {$SETC __UMacApp__ := FALSE}
  24.         {$ENDC}
  25.  
  26.         {$IFC NOT __UMacApp__}
  27.         {$SETC __UMacApp__ := TRUE}
  28.  
  29.         { • Required for this unit's interface. Auto-Include them }
  30.         {$SETC UMacAppIncludes := UsingIncludes}
  31.         {$SETC UsingIncludes := TRUE}
  32.         {$I+}
  33.         {$IFC UNDEFINED __UMacAppUtilities__} {$I UMacAppUtilities.p} {$ENDC}
  34.         {$IFC UNDEFINED __UObject__} {$I UObject.p} {$ENDC}
  35.         {$IFC UNDEFINED __UList__} {$I UList.p} {$ENDC}
  36.         {$IFC UNDEFINED __UAssociation__} {$I UAssociation.p} {$ENDC}
  37.         {$IFC UNDEFINED __UFailure__} {$I UFailure.p} {$ENDC}
  38.         {$IFC UNDEFINED __UPatch__} {$I UPatch.p} {$ENDC}
  39.         {$IFC UNDEFINED __UMemory__} {$I UMemory.p} {$ENDC}
  40.         {$IFC UNDEFINED __UMenuSetup__} {$I UMenuSetup.p} {$ENDC}
  41.         {$IFC UNDEFINED __UViewCoords__} {$I UViewCoords.p} {$ENDC}
  42.  
  43.         {$IFC UNDEFINED UsingScrap} {$I Scrap.p} {$ENDC}
  44.         {$IFC UNDEFINED UsingWindows} {$I Windows.p} {$ENDC}
  45.         {$IFC UNDEFINED UsingDialogs} {$I Dialogs.p} {$ENDC}
  46.         {$SETC UsingIncludes := UMacAppIncludes}
  47.  
  48.         CONST
  49.             kCopyright            =
  50.                    'MacApp® 2.0.1 Copyright © 1984-1990 Apple Computer, Inc.  All rights reserved.'
  51.             ;
  52.  
  53.             { M E N U S }
  54.             kMBarDisplayed        = 128;                    { Default 'MBAR' id of the menus that are
  55.                                                          read in and installed in menu bar }
  56.             kMBarNotDisplayed    = 129;                    { Default 'MBAR' id of the menus that are
  57.                                                          read in but not installed }
  58.             kMBarHierarchical    = 130;                    { Default 'MBAR' id of the menus that pop up
  59.                                                          when a menu item is choosen }
  60.  
  61.             { C O M M A N D S }
  62.  
  63.             { Negative numbers and positive numbers up to 999 are reserved by MacApp }
  64.             { Predefined command numbers ??? Renumber these more logically ??? }
  65.             { Not all of these are caught by MacApp.
  66.             "<!>" means MacApp catches it.
  67.             "<&>" means TEView catches it.
  68.             "<->" means the application must catch it if it is used as a
  69.             command number in any menu."
  70.  
  71.             {Special command codes }
  72.  
  73.             cNoCommand            = 0;                    { <!> Command number representing no command
  74.                                                          }
  75.             cCantUndo            = - 1;                    { <!> Passed to TApplication.SetUndoText to
  76.                                                          indicate that the command cannot be
  77.                                                          undone. }
  78.  
  79.             { Apple-menu commands }
  80.  
  81.             cAboutApp            = 1;                    { <!> "About <appname>…" }
  82.  
  83.             { File-menu filing commands }
  84.  
  85.             cNew                = 10;                    { <!> "New" (??? reserve a range of NEW
  86.                                                          commands ???) }
  87.             cNewLast            = 19;
  88.             cOpen                = 20;                    { <!> "Open …" (??? reserve a range of OPEN
  89.                                                          commands ???) }
  90.             cOpenLast            = 29;
  91.  
  92.             cSave                = 30;                    { <!> "Save" }
  93.             cClose                = 31;                    { <!> "Close" }
  94.             cSaveAs             = 32;                    { <!> "Save as…" }
  95.             cSaveCopy            = 33;                    { <!> "Save a Copy in …" }
  96.             cRevert             = 34;                    { <!> "Revert" (to previous version) }
  97.             cShowClipboard        = 35;                    { <!> "Show Clipboard"/"Hide Clipboard" }
  98.             cQuit                = 36;                    { <!> "Quit" }
  99.  
  100.             { Edit-menu commands }
  101.  
  102.             { For the following command numbers, we must guarantee that
  103.             <command number> - cEditBase = <appropriate number to pass to
  104.             SystemEdit>.  This relationship is enforced in
  105.             TApplication.IApplication. }
  106.             cEditBase            = 101;                    { start of standard editing commands }
  107.             cUndo                = 101;                    { <!> "Undo <command>"/"Redo <command>" }
  108.             cEditSep            = 102;                    { line separating UNDO from CUT }
  109.             cCut                = 103;                    { <&> "Cut" }
  110.             cCopy                = 104;                    { <&> "Copy" }
  111.             cPaste                = 105;                    { <&> "Paste" }
  112.             cClear                = 106;                    { <-> "Clear" }
  113.             cEditLast            = cClear;
  114.  
  115.             cSelectAll            = 110;                    { <&> "Select All" }
  116.  
  117.             cTyping             = 120;                    { for use in a TTypingCommand }
  118.             cMouseCommand        = 121;                    { generic mouse command }
  119.  
  120.             cStyleChange        = 130;                    { "Menu" command for style change }
  121.             cRememberStyle        = 131;                    { "Menu" command for remembering present
  122.                                                          style }
  123.  
  124.             { Finder pseudo-commands }
  125.  
  126.             cFinderNew            = 40;                    { <!> The user selected the tool icon in the
  127.                                                          Finder and chose "Open" }
  128.             cFinderPrint        = 41;                    { <!> The user selected document icons in
  129.                                                          the Finder and chose "Print" }
  130.             cFinderOpen         = 42;                    { <!> The user selected document icons in
  131.                                                          the Finder and chose "Open" }
  132.  
  133.             { File-menu printing commands  }
  134.  
  135.             cPrFileBase         = 176;                    { Command numbers between cPrFileBase and
  136.                                                          cPrFileMax are sent to a document's
  137.                                                          fDocPrintHandler even if it is not in the
  138.                                                          fTarget chain }
  139.             cPrFileMax            = 195;
  140.  
  141.             cPageSetup            = 176;                    { <!> "Page Setup…" }
  142.             cPrintOne            = 177;                    { <!> "Print One" }
  143.             cPrint                = 178;                    { <!> "Print…" }
  144.             cPrintToFile        = 179;                    { <!> "Print to file…" }
  145.  
  146.             cPrintSpoolFile     = 190;                    { <-> "Print spooled file…" }
  147.  
  148.             cPrViewBase         = 201;                    { Command numbers between cPrViewBase and
  149.                                                          cPrViewMax are printing commands applied
  150.                                                          to a displayed view in the fTarget chain }
  151.             cPrViewMax            = 250;
  152.  
  153.             cShowBorders        = 199;                    { <!> Toggle. "Show view borders"--also
  154.                                                          usable outside Debug menu }
  155.  
  156.             { Zooming commands }                        { Not being used at present }
  157.  
  158.             cReduce50            = 301;                    { <-> "Reduce 50%" }
  159.             cReduceToFit        = 302;                    { <-> "Reduce to Fit" }
  160.             cShowFullSize        = 303;                    { <-> "Show Full Size" }
  161.  
  162.             { Control tracking }
  163.             cTrackingControl    = 400;
  164.  
  165.             { Debug-menu commands.    Flag toggled by "cFoo" is called "gFoo" for any
  166.             "Foo" }
  167.  
  168.             cIdentifySoftware    = 900;                    { <!> Action. "Show Software Version"--
  169.                                                          WriteLn version info }
  170.             cExperimenting        = 901;                    { <!> Toggle. "Enable experimental features"
  171.                                                          }
  172.             cReportMenuChoices    = 902;                    { <!> Toggle. "Trace menu commands"--
  173.                                                          WriteLn menu choices }
  174.             cIntenseDebugging    = 904;                    { <!> Toggle. "Intense Debugging" }
  175.             cTraceSetupMenus    = 905;                    { <!> Toggle. "Allow Trace of Menu Setups"
  176.                                                          if gTrace is also on }
  177.             cTraceIdle            = 906;                    { <!> Toggle. "Allow Trace during Idle" if
  178.                                                          gTrace is also on }
  179.             cDebugPrinting        = 912;                    { <!> Toggle. "Debug Printing" }
  180.             cReportEvt            = 914;                    { <!> Toggle. "Report Events"--WriteLn
  181.                                                          events received from queue }
  182.             cDoFirstClick        = 915;                    { <!> Toggle. "'Do First Click' for this
  183.                                                          window" }
  184.             cVarClipPicSize     = 916;                    { <!> Toggle. "Scale Pictures in Clipboard
  185.                                                          to Window" }
  186.             cRefreshFrontWindow = 917;                    { <!> Action. "Refresh Front Window" }
  187.             cNewInspectorWindow = 918;                    { <!> Action. "Open new inspector window" }
  188.             cModalToggle        = 919;                    { <!> Toggle. "Make front window
  189.                                                          modal/modeless"}
  190.             cDebugWind            = 913;                    { <!> Action. "Show Debug Window" }
  191.             cEnterMacAppDebugger = 920;                 { <!> Action. "Enter the MacApp Debugger" }
  192.  
  193.             cSetSysJust            = 921;                     { <!> Action. "Switch system justification" }
  194.  
  195.  
  196.             { D E B U G  F L A G S }
  197.  
  198.             {$IFC NOT qDebug}                            { These start with 'g' because they are
  199.                                                          global variables when qDebug is TRUE }
  200.             gExperimenting        = FALSE;
  201.             gReportMenuChoices    = FALSE;
  202.             gIntenseDebugging    = FALSE;
  203.             gDebugPrinting        = FALSE;
  204.             gReportEvt            = FALSE;
  205.  
  206.             gMemMgtReport        = FALSE;
  207.             gAssumeFocused        = FALSE;
  208.             {$ENDC}
  209.  
  210.             { A L E R T S }
  211.  
  212.             errReasonID         = 128;                    { resource ID of errs resource describing
  213.                                                          error messages }
  214.             errRecoveryID        = 129;                    { resource ID of errs resource describing
  215.                                                          recovery messages }
  216.             errOperationsID     = 130;                    { resource ID of errs resource containing
  217.                                                          operation strings }
  218.             errAppTable         = 1000;                 { added to the MacApp resource ID to get the
  219.                                                          ID of an application error table }
  220.  
  221.             msgCmdErr            = 0;                    { when added to a command number, gives a
  222.                                                          message value to display the alert "Could
  223.                                                          not complete the … command …" }
  224.             msgAlert            = $FFFF0000;            { when added to an alert number, gives a
  225.                                                          message value to display that alert }
  226.             msgLookup            = $FFFE0000;            { when added to an INTEGER, gives a message
  227.                                                          value that will look up the INTEGER in
  228.                                                          table errOperationsID and display the
  229.                                                          alert "Could not … because …" }
  230.             msgAltRecovery        = $FFFD0000;            { same as msgLookup, except the INTEGER is
  231.                                                          used instead of the error number to lookup
  232.                                                          the recovery string }
  233.  
  234.             msgStrList            = 130 * $10000;         { Standard list of operation strings used by
  235.                                                          MacApp * $10000 to plunk it into hiwrd }
  236.             msgCancelled        = msgStrList;            { used with error = noErr if user cancels
  237.                                                          Save, Quit, … }
  238.             msgInitFailed        = msgStrList + 1;
  239.             msgSaveFailed        = msgStrList + 2;
  240.             msgRevertFailed     = msgStrList + 3;
  241.             msgPrintFailed        = msgStrList + 4;
  242.             msgNewFailed        = msgStrList + 5;
  243.             msgOpenFailed        = msgStrList + 6;
  244.             msgSaveAsFailed     = msgStrList + 7;
  245.             msgSaveCopyFailed    = msgStrList + 8;
  246.             msgDrawFailed        = msgStrList + 9;
  247.             msgImportClipFailed = msgStrList + 10;
  248.             msgExportClipFailed = msgStrList + 11;
  249.  
  250.             { error codes used in MacApp; applications should use errors between
  251.             -25000 and -29999 }
  252.  
  253.             errSpooling         = - 20000;                { print spooling failed OSErr }
  254.             errRevertFNF        = - 20001;                { Revert failed because file was deleted }
  255.             errFileChanged        = - 20002;                { disk file modification date changed }
  256.             errSaveAgain        = - 20003;                { Save As / Save a Copy in an opened
  257.                                                          document }
  258.             errFTypeChanged     = - 20004;                { disk file type changed }
  259.             errNoPrintDrvr        = - 20005;                { print driver file not found }
  260.             errNotMyType        = - 20006;                { can't open this file type }
  261.             errNotImplemented    = - 20007;                { Signaled when a function is not yet
  262.                                                          implemented }
  263.             errMissingClass        = - 20008;                { Signaled when a class is missing. Usually
  264.                                                         due to failure to dead-strip suppress when
  265.                                                         creating objects any other way than by "NEW" }
  266.  
  267.             { Alerts 0 - 249 are reserved by MacApp. }
  268.  
  269.             phGenError            = 128;                    { 'Could not ^2, because ^0. ^1' }
  270.             phCmdErr            = 129;                    { 'Could not complete the “^2” command
  271.                                                          because ^0. ^1'. }
  272.             phUnknownErr        = 130;                    { 'Could not complete your request because
  273.                                                          ^0. ^1'; only used if no operation is
  274.                                                          supplied. }
  275.             phSaveChanges        = 131;                    { 'Save Changes Before Closing?' }
  276.             phRevert            = 132;                    { 'Revert to last version saved?' }
  277.             phFileChanged        = 133;                    { 'File changed since last save.' }
  278.             phPurgeOld            = 134;                    { 'OK to purge old version before saving new
  279.                                                          one?' }
  280.             phReopenDoc         = 135;                    { 'Document is already open.' }
  281.             phSpaceIsLow        = 136;                    { 'Space is low' }
  282.             phUnsupportedConfiguration = 137;            { 'Can't start app because your machine is
  283.                                                          too wimpy!' }
  284.             phOfferReadOnly     = 138;                    { 'Can't open for file for write. Open
  285.                                                          read-only?' }
  286.  
  287.             phTooManyChars        = 150;                    { 'Too Many Characters', used to reject
  288.                                                          paste or keystrokes in UDialog and UTEView
  289.                                                          }
  290.  
  291.             phStylesTooBig        = 151;                    { 'Too Many Styles', used to reject the
  292.                                                          styles portion of a paste in UTEView }
  293.  
  294.             phAboutApp            = 201;                    { Can hold the 'About <appName>…' message }
  295.  
  296.             phUnimplemented     = 202;                    { 'This feature not yet implemented' }
  297.  
  298.             { M A C A P P    B U Z Z - S T R I N G    R E S O U R C E }
  299.             kIDBuzzString        = 250;                    { std list of buzzwords stored as 'STR#'
  300.                                                          resources. This string list is reserved
  301.                                                          for MacApp; you should choose a different
  302.                                                          resource ID for your strings. }
  303.  
  304.             { Indices for strings in the buzz-string resource }
  305.             bzSaveAs            = 1;                    { 'Save This Document As:' }
  306.             bzSaveCopy            = 2;                    { 'Save a Copy In:' }
  307.             bzShowClip            = 3;                    { 'Show Clipboard' }
  308.             bzHideClip            = 4;                    { 'Hide Cllpboard' }
  309.             bzUndo                = 5;                    { 'Undo x' }
  310.             bzRedo                = 6;                    { 'Redo x' }
  311.             bzCantDraw            = 7;                    { 'Unable to draw contents of window' }
  312.             bzUntitled            = 8;                    { name of untitled document; if blank then
  313.                                                          this is taken from the window title
  314.                                                          template; if this includes the string
  315.                                                          '<<<>>>' then MacApp will substitute a
  316.                                                          number for the string (e.g., if the buzz
  317.                                                          string contains 'Untitled-<<<>>>' then
  318.                                                          untitled windows will be named
  319.                                                          'Untitled-1', Untitled-2, … }
  320.             bzClosing            = 9;                    { 'closing' }
  321.             bzQuitting            = 10;                    { 'quitting' }
  322.             bzCantUndo            = 11;                    { 'Can’t Undo' }
  323.             bzSaveAnyways        = 12;                    { 'save' }
  324.             bzRevertAnyways     = 13;                    { 'revert' }
  325.  
  326.             { D E B U G   B U Z Z - S T R I N G   R E S O U R C E }
  327.             kDebugBuzzStrings    = 251;                    { Debug buzzwords STR# resource }
  328.             bzMakeModal         = 1;                    { 'Make Front Window Modal' }
  329.             bzMakeModeless        = 2;                    { 'Make Front Window Modeless' }
  330.             bzDoFirstClick        = 3;                    { 'Do First Click For This Window' }
  331.             bzDontDoFirstClick    = 4;                    { 'Don't Do First Click For This Window' }
  332.             bzSetRightSysJust    = 5;                    { Set system to right justification }
  333.             bzSetLeftSysJust    = 6;                    { Set system to left justification }
  334.  
  335.             { R E S O U R C E    I D S }
  336.             { Negative numbers and numbers up to 127 are reserved by Apple }
  337.             { Positive numbers from 128 up to 999 are reserved by MacApp }
  338.             kDefaultCredits     = 1001;                 { People responsible for the application }
  339.             kIDClipWindow        = 200;                    { window displaying the Clipboard }
  340.             kScrollBarId        = 202;                    { for when we create scrollers from
  341.                                                          resources }
  342.             kDebugParamsID        = 300;                    { debug window }
  343.  
  344.             { V I E W    I D E N T I F I E R S }
  345.             { These follow the same reservation rules as resource types }
  346.  
  347.             kDefaultWindowID    = 1001;                 { Window view resource installed by default
  348.                                                          in TDocument }
  349.             kDefaultViewID        = 1002;                 { View resource installed by default in
  350.                                                          TDocument }
  351.             kIDDefaultView        = 'DFLT';                { View ID of default view }
  352.             kIDClipView         = 'CLIP';                { identifier of the clipboard "orhanage" }
  353.  
  354.             { O B J E C T  S I G N A T U R E S }
  355.             { These follow the same reservation rules as resource types }
  356.             { The signature is used to search the signature table and create
  357.             an object "by signature"  If the signature's entry in the table has
  358.             been updated with a new class then an object of that class will be created. }
  359.  
  360.             kStdDocument        = 'docu';
  361.             kStdTracker         = 'trak';
  362.             kStdList            = 'list';
  363.  
  364.             kStdButton            = 'butn';
  365.             kStdCheckBox        = 'chkb';
  366.             kStdCluster         = 'clus';
  367.             kStdControl         = 'cntl';
  368.             kStdDefaultView     = 'dflt';
  369.             kStdDialogView        = 'dlog';
  370.             kStdEditText        = 'edit';
  371.             kStdGridView        = 'grid';
  372.             kStdIcon            = 'icon';
  373.             kStdNumberText        = 'nmbr';
  374.             kStdPattern         = 'patn';
  375.             kStdPicture         = 'pict';
  376.             kStdPopup            = 'popp';
  377.             kStdRadio            = 'radb';
  378.             kStdScroller        = 'scrl';
  379.             kStdSScrollBar        = 'sbar';
  380.             kStdStaticText        = 'stat';
  381.             kStdTEView            = 'tevw';
  382.             kStdTextGridView    = 'txtg';
  383.             kStdTextListView    = 'lstg';
  384.             kStdView            = 'view';
  385.             kStdWindow            = 'wind';
  386.  
  387.             { H I G H L I G H T I N G }
  388.             hlOff                = 1;                    { the selection is to be unhighlighted }
  389.             hlDim                = 2;                    { the selection is to be dimly highlighted }
  390.             hlOn                = 4;                    { the selection is to be fully highlighted }
  391.  
  392.             { these constants can be used to test for combinations of fromHL+toHL,
  393.             when you do not care which is from and which is to }
  394.             hlOffDim            = hlOff + hlDim;
  395.             hlDimOff            = hlOffDim;
  396.             hlDimOn             = hlDim + hlOn;
  397.             hlOnDim             = hlDimOn;
  398.             hlOffOn             = hlOff + hlOn;
  399.             hlOnOff             = hlOffOn;
  400.  
  401.             { C H O I C E S }
  402.  
  403.             { Negative numbers and positive numbers up to 999 are reserved by MacApp }
  404.             mOKHit                = 1;
  405.             mCancelHit            = 2;
  406.             mButtonHit            = 3;
  407.             mCheckBoxHit        = 4;
  408.             mClusterHit         = 5;
  409.             mEditTextHit        = 6;
  410.             mIconHit            = 7;
  411.             mListItemHit        = 8;
  412.             mListScrollBarHit    = 9;
  413.             mPictureHit         = 10;
  414.             mPopupHit            = 11;
  415.             mRadioHit            = 12;
  416.             mStaticTextHit        = 13;
  417.             mHScrollBarHit        = 14;
  418.             mVScrollBarHit        = 15;
  419.             mEditTabKey         = 16;
  420.             mEditReturnKey        = 17;
  421.             mEditEnterKey        = 18;
  422.             mPatternHit         = 19;
  423.             mControlHit         = 20;
  424.             mCancelKey            = 21;
  425.             mDefaultKey         = 22;
  426.  
  427.             kNoIdentifier        = '    ';
  428.             kNoTemplate         = - 1;
  429.             kNoResource         = - 1;
  430.  
  431.             { M I S C E L L A N E O U S }
  432.             kStdMainFileType    = 'TEXT';                { the file type identifier used by default }
  433.  
  434.             kYesButton            = 1;                    { the 'Yes' button in various dialogs }
  435.             kNoButton            = 3;                    { the 'No' button in various dialogs }
  436.  
  437.             kLowSpaceInterval    = 2 * 60 * 60;            { default low space msg interval (2 seconds)
  438.                                                          }
  439.  
  440.             kStdScrollUnit        = 16;                    { default value of fScrollUnit used by
  441.                                                          scrollers }
  442.  
  443.             kSBarSize            = 16;
  444.             kSBarSizeMinus1     = kSBarSize - 1;
  445.             { !!! Prefer the above names }
  446.             kStdSzSBar            = 16;                    { width/height of a standard
  447.                                                          vertical/horizontal scroll bar }
  448.             kStdSzMinus1SBar    = kStdSzSBar - 1;
  449.  
  450.             kStdStaggerAmount    = 16;                    { standard # of pixels to stagger windows }
  451.  
  452.             kMaxIdleTime        = MAXLONGINT;            { Default tick count sent to WaitNextEvent }
  453.  
  454.             { Numbers to pass to SystemEdit }
  455.             kSysUndo            = 0;
  456.             kSysCut             = 2;
  457.             kSysCopy            = 3;
  458.             kSysPaste            = 4;
  459.             kSysClear            = 5;
  460.  
  461.             {$IFC qDebug}
  462.             kRsrcCheckInterval    = 100;
  463.             {$ENDC}
  464.  
  465.             kPriorityLowest     = 127;                    { Low priority commands are considered last
  466.                                                          }
  467.             kPriorityLow        = kPriorityLowest - 32; { Low priority commands are considered last
  468.                                                          }
  469.             kPriorityNormal     = 64;                    { Normal priority assigned to commands by
  470.                                                          default }
  471.             kPriorityHighest    = 0;                    { High priority commands take precedence }
  472.             kPriorityHigh        = kPriorityHighest + 32; { High priority commands take precedence }
  473.  
  474.             kBuild                = TRUE;                 { Pass to TWindow.BuildWindowRgns }
  475.             kAllowApplicationToSleep = TRUE;            { Pass to TApplication.PollEvent if the
  476.                                                          application is allowed to sleep if there
  477.                                                          are no events pending. }
  478.             { P R I N T I N G }
  479.             kSquareDots         = TRUE;                 { Square dots in Printing }
  480.             kFixedSize            = TRUE;                 { Fixed Page Size in Printing }
  481.  
  482.             kPrintInfoSize        = 120;                    { size in bytes of printInfo record }
  483.  
  484.             { size in bytes of the overhead for a resource file;
  485.             kRsrcFileOverhead is added in TDocument.DoNeedDiskSpace if the
  486.             document uses the rsrc fork.
  487.             You should add kRsrcTypeOverhead for each unique type you use
  488.             plus kRsrcOverhead for each resoruce you use
  489.             plus the total bytes in all the resources
  490.             plus the length of all the names for named resources. }
  491.             kRsrcFileOverhead    = 256 +                 { resource header & stuff }
  492.                                   30                    { fixed part of resource map } ;
  493.             kRsrcTypeOverhead    = 8;                    { overhead for each resource type }
  494.             kRsrcOverhead        = 16;                    { overhead for each resource }
  495.  
  496.             { ??? }
  497.             kViewRsrcExpandAmt    = $400;                 { ??? Is 1K enough for expansion, or too
  498.                                                          much maybe??? }
  499.  
  500.             { debugging info }
  501.             kDebugFont            =                        {monaco} 4; { Font for Debug Window }
  502.             kDebugSize            = 9;                    { Font size for Debug Window }
  503.  
  504.             { argument of TDocument.DoMakeViews }
  505.             kForDisplay         = FALSE;
  506.             kForPrinting        = NOT kForDisplay;
  507.  
  508.             { arguments of TScroller.IScroller }
  509.             kWantHScrollBar     = TRUE;
  510.             kWantVScrollBar     = TRUE;
  511.  
  512.             { arguments of TDocument.Save }
  513.             kAskForFilename     = TRUE;
  514.             kMakingCopy         = TRUE;
  515.             kSwitchToTarget     = NOT kMakingCopy;
  516.  
  517.             { argument of NewPaletteWindow }
  518.             kLeftPalette        = h;
  519.             kTopPalette         = v;
  520.  
  521.             { argument of TApplication.SetUndoText }
  522.             kShowUndo            = TRUE;
  523.             kShowRedo            = FALSE;
  524.             kShowCantUndo        = kShowUndo;
  525.  
  526.             { argument of TDocument.IDocument }
  527.             kUsesDataFork        = TRUE;
  528.             kUsesRsrcFork        = TRUE;
  529.             kDataOpen            = TRUE;
  530.             kRsrcOpen            = TRUE;
  531.  
  532.             { argument of TDocument.OpenDocFile }
  533.             kKeepingOpen        = TRUE;
  534.             kReadingFile        = TRUE;
  535.  
  536.             kVisible            = TRUE;
  537.             kInvisible            = FALSE;
  538.  
  539.             { arguments to routines with a 'redraw' parameter }
  540.             kRedraw             = TRUE;
  541.             kDontRedraw         = FALSE;
  542.  
  543.             { arguments to routines with an 'invalidate' parameter }
  544.             kInvalidate         = TRUE;
  545.             kDontInvalidate     = FALSE;
  546.  
  547.             { MultiFinder event message masks }
  548.             kSuspendOrResume    = $01;
  549.             kMouseMovedMessage    = $FA;
  550.  
  551.             kMaxSignatures        = 32;
  552.  
  553.         TYPE
  554.  
  555.             { E V E N T S }
  556.  
  557.             EventRecordPtr        = ^EventRecord;         { EventRecord is a ToolBox type. The pointer
  558.                                                          type _MUST_ be declared first since the
  559.                                                          record is self referential }
  560.             EventInfo            = RECORD                { stores more information about the event in
  561.                                                          an unpacked form }
  562.                 thePEvent:            EventRecordPtr;     { pointer to the original packed ToolBox
  563.                                                          event record }
  564.                 theBtnState:        BOOLEAN;            { bits found in the modifiers field of an
  565.                                                          EventRecord }
  566.                 theCmdKey:            BOOLEAN;            { Was Command key depressed? }
  567.                 theShiftKey:        BOOLEAN;            { Was Shift key depressed? }
  568.                 theAlphaLock:        BOOLEAN;            { Was Alpha Lock depressed? }
  569.                 theOptionKey:        BOOLEAN;            { Was Option key depressed? }
  570.                 theControlKey:        BOOLEAN;            { Was Control key depressed? }
  571.                 theAutoKey:         BOOLEAN;            { TRUE if this was an auto key event }
  572.                 theCharacter:        Char;                { IF a key event the char that the event
  573.                                                         translates to !!! what about 16 bit chars? }
  574.                 theKeyCode:            INTEGER;            { IF a key event the virtual key code that the
  575.                                                         event translates to }
  576.  
  577.                 theClickCount:        INTEGER;            { 0 = event was not a mouse down; 1-N = # of
  578.                                                          multiple clicks }
  579.                 affectsMenus:        BOOLEAN;            { True means the menus must be setup after
  580.                                                          the event }
  581.                 END;
  582.             PEventRecord        = EventRecordPtr;        { Left in for compatibility (2.0) }
  583.  
  584.             IdlePhase            = (idleBegin, idleContinue, idleEnd);
  585.             TrackPhase            = (trackPress            {actually trackBegin} , trackMove {actually
  586.                                        trackContinue} , trackRelease {actually trackEnd} );
  587.  
  588.             { V I E W  C O O R D I N A T E S }
  589.  
  590.             SizeDeterminer        =                        { Tells how a view's size is to be
  591.                                                          determined; specified separately in each
  592.                                                          dimension. }
  593.             (sizeSuperView,                             { View is the same size as its superview }
  594.              sizeRelSuperView,                            { View size is relative to the superview's
  595.                                                          size }
  596.              sizePage,                                    { View to be the size of one page }
  597.              sizeFillPages,                             { View to grow upward to fill an exact
  598.                                                          number of pages }
  599.              sizeVariable,                                { View size fluctuates according to
  600.                                                          app-specific criteria }
  601.              sizeFixed);                                { No special default handling of size issues
  602.                                                          }
  603.  
  604.             { H I G H L I G H T I N G }
  605.             HLState             = hlOff..hlOn;
  606.  
  607.             { D O C U M E N T S }
  608.             { How to save a document in place, if MacApp decides this is needed.
  609.             sipNever: never save on top of old file (ie., save will fail if
  610.             there is not enough disk space)
  611.             sipAlways: save on top of old file without asking user
  612.             sipAskUser: save on top, but only if user confirms
  613.             }
  614.             SIPChoice            = (sipNever, sipAlways, sipAskUser);
  615.  
  616.             { O T H E R }
  617.             AppFilePtr            = ^AppFile;             { AppFile is segment loader section of
  618.                                                          Inside Macintosh }
  619.             PAppFile            = AppFilePtr;            { Left in for compatibility (2.0) }
  620.  
  621.             ArrTypeList         = ARRAY [1..8000] OF OSType;
  622.             TypeListPtr         = ^ArrTypeList;         { Preferred }
  623.             TypeListHandle        = ^TypeListPtr;         { Preferred }
  624.             PTypeList            = TypeListPtr;            { Left in for compatibility (2.0) }
  625.             HTypeList            = TypeListHandle;        { Left in for compatibility (2.0) }
  626.  
  627.             CommandPriority     = kPriorityHighest..kPriorityLowest; { Command priorities }
  628.  
  629.             {$IFC qHasForward}
  630.             TCommand             = OBJECT;    FORWARD;
  631.             TDocument            = OBJECT;    FORWARD;
  632.             TPrintHandler        = OBJECT;    FORWARD;
  633.             TView                 = OBJECT;    FORWARD;
  634.             TWindow                = OBJECT;    FORWARD;
  635.             TCommandList        = OBJECT;    FORWARD;
  636.             TScroller            = OBJECT;    FORWARD;
  637.             TSScrollBar            = OBJECT;    FORWARD;
  638.             {$EndC}
  639.  
  640.             TEvtHandler         = OBJECT (TObject)        { The TEvtHandler type represents abstract
  641.                                                          objects that handle certain kinds of
  642.                                                          events: Key events: both key down and auto
  643.                                                          key events, menu events: both enabling
  644.                                                          menus and menu items and processing menu
  645.                                                          commands, Read to/write from Disk, Idle
  646.                                                          events: when there are no other events to
  647.                                                          handle, Actual events: EvtHandlers -
  648.                                                          through their method 'DoHandleEvent' may
  649.                                                          intercept and handle actual ToolBox events
  650.                                                          Termination: when the application quits
  651.                                                          TEvtHandler are linked into a list with
  652.                                                          the most specific object (usually a
  653.                                                          selection) at the head of the list. The
  654.                                                          global variable 'gTarget' contains the
  655.                                                          head of the list. (When a window is
  656.                                                          deactivated, this global variable is
  657.                                                          cached in the window object, and retrieved
  658.                                                          when it is later activated.) For these
  659.                                                          kinds of events, the target (gTarget) gets
  660.                                                          the first crack at handling the event. The
  661.                                                          default implementation of the methods of
  662.                                                          TEvtHandler is to pass the event to the
  663.                                                          next element of the list. }
  664.  
  665.                 fNextHandler:        TEvtHandler;        { the next element of the list, or NIL }
  666.                 fIdleFreq:            LONGINT;            { the minimum number of ticks that can pass
  667.                                                          before my DoIdle is called. 0 = call as
  668.                                                          often as possible. n..kMaxIdleTime = call
  669.                                                          every fIdleFreq ticks. }
  670.                 fLastIdle:            LONGINT;            { the tick count the last time my DoIdle was
  671.                                                          called. }
  672.  
  673.                                 { Init & Free }
  674.                 PROCEDURE TEvtHandler.IEvtHandler(itsNextHandler: TEvtHandler);
  675.                 { Sets up the reference to the next handler by setting the fNextHandler field to
  676.                 'itsNextHandler', also sets the idle frequency and resets fLastIdle field to zero.
  677.                 }
  678.  
  679.                 PROCEDURE TEvtHandler.Free; OVERRIDE;
  680.                 { Before calling inherited Free, changes the target to the application if the next
  681.                 handler is NIL or the next handler if there is one. }
  682.  
  683.                 { Termination }
  684.                 PROCEDURE TEvtHandler.Terminate;
  685.                 { Does nothing in this class. }
  686.  
  687.                 { Chainwalking }
  688.                 PROCEDURE TEvtHandler.EachHandler(PROCEDURE
  689.                                                   DoToEvtHandler(anEvtHandler: TEvtHandler));
  690.                 { Performs 'DoToEvtHandler' to aFirstHandler, then to its fNextHandler, etc., onward
  691.                 until the fNextHandler chain ends at NIL }
  692.  
  693.                 FUNCTION TEvtHandler.FirstHandlerThat(FUNCTION
  694.                                                       TestEvtHandler(anEvtHandler: TEvtHandler):
  695.                                                       BOOLEAN): TEvtHandler;
  696.                 { Calls TestEvtHandler for each event handler until TestEvtHandler returns true.
  697.                 Returns the TEvtHandler object for which TestEvtHandler returned true, or NIL if
  698.                 TestEvtHandler never returned true. }
  699.  
  700.                 FUNCTION TEvtHandler.AddHandler(headOfChain: TEvtHandler): TEvtHandler;
  701.                 { Adds SELF from the chain of handlers starting at headOfChain. Returns the new
  702.                 head of chain. }
  703.  
  704.                 FUNCTION TEvtHandler.RemoveHandler(headOfChain: TEvtHandler): TEvtHandler;
  705.                 { Removes SELF from the chain of handlers starting at headOfChain.    Returns the new
  706.                 head of chain (if self was the head then there _must_ be a new head. }
  707.  
  708.                 { Debugging }
  709.                 PROCEDURE TEvtHandler.IdentifySoftware;
  710.                 { If fNextHandler is not NIL calls the next handler's IdentifySoftware method. }
  711.  
  712.                 FUNCTION TEvtHandler.LookupSymbol(VAR sym: Str255): LONGINT;
  713.                 { Called by the debugger to translate a symbol into a number; default passes to the
  714.                 fNextHandler. sym will be uppercased. Return of -1 means symbol was not found. If
  715.                 sym = '?' then writeln a list of available symbols. }
  716.  
  717.                 PROCEDURE TEvtHandler.Fields(PROCEDURE
  718.                                              DoToField(fieldName: Str255;
  719.                                                        fieldAddr: Ptr;
  720.                                                        fieldType: INTEGER)); OVERRIDE;
  721.                 { Used by the Inspector and the Debugger to display the contents of this class's
  722.                 fields. }
  723.  
  724.                 { Events }
  725.                 FUNCTION TEvtHandler.DoIdle(phase: IdlePhase): BOOLEAN;
  726.                 { Returns true if it frees itself so caller can know }
  727.  
  728.                 FUNCTION TEvtHandler.DoHandleEvent(nextEvent: EventRecordPtr;
  729.                                                    VAR commandToPerform: TCommand): BOOLEAN;
  730.                 { Handle the event and return TRUE if I want it, else I don't handle it, and return
  731.                 FALSE }
  732.  
  733.                 { Double/Triple Clicks }
  734.                 FUNCTION TEvtHandler.DoMultiClick(lastDownPt, newDownPt: Point): BOOLEAN;
  735.                 { Called by TApplication.CountClicks. Should return TRUE if the 2 points are close
  736.                 enough to be considered part of a double/triple click. (Both points are in global
  737.                 coordinates.) This is only called if the mouse down was within the proper time
  738.                 range of the previous mouse up. Default is to pass message to the nextEventHandler
  739.                 (if one exists), otherise to require that the sum of the x & y distances is <=
  740.                 gStdHysteresis. }
  741.  
  742.                 { Key Events }
  743.                 FUNCTION TEvtHandler.DoKeyCommand(ch: Char;
  744.                                                   aKeyCode: INTEGER;
  745.                                                   VAR info: EventInfo): TCommand;
  746.                 { Handles all keystrokes except those with the command key held down. }
  747.  
  748.                 FUNCTION TEvtHandler.DoCommandKey(ch: Char;
  749.                                                   VAR info: EventInfo): TCommand;
  750.                 { Handles command-key combinations only. }
  751.  
  752.                 PROCEDURE TEvtHandler.KeyEventToComponents(VAR info: EventInfo);
  753.                 { Intended to extract character components of an event in a script manager
  754.                 compatible way.  Default just forwards to next handler }
  755.  
  756.                 { MenuEvents }
  757.                 FUNCTION TEvtHandler.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
  758.                 { If the handler can perform the command it does so by either performing
  759.                 the command directly or by returning a TCommand. }
  760.  
  761.                 PROCEDURE TEvtHandler.DoSetupMenus;
  762.                 { Handles the setup of menus. }
  763.  
  764.                 { Help }
  765.  
  766.                 FUNCTION TEvtHandler.DoHelp(VAR info: EventInfo;
  767.                                             VAR message: UNIV LONGINT): TCommand;
  768.                 { If fNextHandler is not NIL calls its DoHelp method, otherwise returns NIL. }
  769.  
  770.                 { View Creation from Templates}
  771.                 FUNCTION TEvtHandler.DoCreateViews(itsDocument: TDocument;
  772.                                                    parentView: TView;
  773.                                                    itsRsrcID: INTEGER;
  774.                                                    subViewOffset: VPoint): TView;
  775.                 { This is the method responsible for creating view hierarchies from resource
  776.                 templates. If fNextHandler is not NIL it calls its DoCreateViews method. Otherwise
  777.                 it creates the desired view heirarchy. }
  778.  
  779.                 FUNCTION TEvtHandler.CreateAView(itsDocument: TDocument;
  780.                                                  itsSuperView: TView;
  781.                                                  VAR itsParams: Ptr): TView;
  782.                 { For creating a single view from a resource template view. If fNextHandler is not
  783.                 NIL calls its CreateAView method, otherwise it proceeds to create the desired view.
  784.                 }
  785.  
  786.                 { Miscellaneous }
  787.                 FUNCTION TEvtHandler.HandlesPrintingCommands: BOOLEAN;
  788.                 { If fNextHandler is not NIL calls its same method setting this method to the result,
  789.                 otherwise returns FALSE. }
  790.  
  791.                 PROCEDURE TEvtHandler.InstallSelection(wasActive, beActive: BOOLEAN);
  792.                 { The Target is told to do this after a window is activated or deactivated. }
  793.  
  794.                 PROCEDURE TEvtHandler.SetIdleFreq(newIdleFreq: LONGINT);
  795.                 { Call to set the handler's idling frequency. }
  796.  
  797.                 PROCEDURE TEvtHandler.DoChoice(origView: TView;
  798.                                                itsChoice: INTEGER);
  799.                 { If its next handler is not NIL calls its DoChoice method.
  800.                 ??? should change the origView parameter to origHandler in a future version? }
  801.  
  802.                 { Command Management }
  803.                 PROCEDURE TEvtHandler.CommitLastCommand;
  804.                 { Commits the last command by calling its Commit method.
  805.                 Default is to hand off to fNextHandler }
  806.  
  807.                 FUNCTION TEvtHandler.GetLastCommand: TCommand;
  808.                 { Returns the last undoable command.  The command returned is not yet committed.
  809.                 Default is to hand off to fNextHandler }
  810.  
  811.                 FUNCTION TEvtHandler.GetNextCommand: TCommand;
  812.                 { Returns a previously posted command.    Nil if there are no queued commands.
  813.                 Default is to hand off to fNextHandler }
  814.  
  815.                 PROCEDURE TEvtHandler.PerformCommand(command: TCommand);
  816.                 { Called to perform the given command.
  817.                 Default is to hand off to fNextHandler }
  818.  
  819.                 PROCEDURE TEvtHandler.PostCommand(command: TCommand);
  820.                 { Called to post a command to a queue for later execution.
  821.                 Default is to hand off to fNextHandler }
  822.  
  823.                 END;
  824.  
  825.             TApplication        = OBJECT (TEvtHandler)    { The purpose of TApplication is to
  826.                                                          implement the main event loop that all
  827.                                                          Macintosh applications must have. There is
  828.                                                          only one instance of TApplication. One
  829.                                                          thing that TApplication does is to
  830.                                                          interpret the raw events that are posted
  831.                                                          and convert them into higher-level events.
  832.                                                          For example, it converts a click in the
  833.                                                          menu bar into a 'menu event' that contains
  834.                                                          the menu ID/item number that was chosen by
  835.                                                          the user. }
  836.  
  837.            { There are not many TApplication variables--they are mostly global variables, for now… }
  838.  
  839.                 fTicksTilNextIdle:    LONGINT;            { Formerly gIdleFreq. Computed number of
  840.                                                          ticks until the next time
  841.                                                          TApplication.Idle needs to be called to
  842.                                                          dole out idle time. Also is the maximum
  843.                                                          waitTicks that we can hand off to
  844.                                                          GetEvent. }
  845.  
  846.                 fTicksOfLastIdle:    LONGINT;            { Formerly gLastIdle. Time in ticks of the
  847.                                                          last time the active chain and cohandlers
  848.                                                          were idled. }
  849.  
  850.                 fCommandQueue:        TCommandList;        { Commands that were posted for execution }
  851.                 fLaunchWithNewDocument: BOOLEAN;        { TRUE (the default) to create a new
  852.                                                          untitled document when the application is
  853.                                                          launched without a document. }
  854.                 fLastCommand:        TCommand;            { the last command done or undone by the
  855.                                                          user }
  856.  
  857.                                 { Init & Free }
  858.                 PROCEDURE TApplication.IApplication(itsMainFileType: OSType);
  859.                 { itsMainFileType should be the the 4-byte file type that this application
  860.                 reads/writes. We require this here so that programmers do not have to explicitly
  861.                 override TApplication.SFGetParms and supply the type there. That is the only place
  862.                 where the main file type is used. }
  863.  
  864.                 PROCEDURE TApplication.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  865.                 { Used to get this class's name by the Inspector. }
  866.  
  867.                 PROCEDURE TApplication.Fields(PROCEDURE
  868.                                               DoToField(fieldName: Str255;
  869.                                                         fieldAddr: Ptr;
  870.                                                         fieldType: INTEGER)); OVERRIDE;
  871.                 { Used by the Inspector and the Debugger to display the contents of this class's
  872.                 fields, in this case the global variables. }
  873.  
  874.                 { Event Handling }
  875.                 FUNCTION TApplication.GetEvent(eventMask: INTEGER;
  876.                                                sleep: LONGINT;
  877.                                                cursorRgn: RgnHandle;
  878.                                                VAR anEvent: EventRecord): BOOLEAN;
  879.                 { Calls WaitNextEvent (or GetNextEvent) with the given event mask, sleep, and cursor
  880.                 region parameters. You can override this if you have an alternate source for
  881.                 events. }
  882.  
  883.                 FUNCTION TApplication.HandleAlienEvent(VAR theEventInfo: EventInfo): TCommand;
  884.                 { This method is called upon to deal with 'application-specific' events }
  885.  
  886.                 PROCEDURE TApplication.MainEventLoop;
  887.                 { Loop on PollEvent until the application is done }
  888.  
  889.                 PROCEDURE TApplication.DispatchEvent(VAR theEventInfo: EventInfo;
  890.                                                      VAR commandToPerform: TCommand);
  891.  
  892.                 PROCEDURE TApplication.HandleEvent(VAR theEvent: EventRecord);
  893.                 { When this is called by MacApp, theEvent is a pointer to the global variable
  894.                 gLastEvent. In special circumstances, you might 'fake' an event record and pass a
  895.                 pointer to it. }
  896.  
  897.                 PROCEDURE TApplication.PostHandleEvent(VAR theEventInfo: EventInfo);
  898.  
  899.                 FUNCTION TApplication.HandleActivateEvent(VAR theEventInfo: EventInfo): TCommand;
  900.                 { Handles activate (and deactivate) events. Calls the window's Activate method, and
  901.                 sets gRedrawMenuBar to true if activating the window. Returns NIL. }
  902.  
  903.                 FUNCTION TApplication.HandleDiskEvent(VAR theEventInfo: EventInfo): TCommand;
  904.                 { Handles disk events. Calls DIBadMount if the high word of theEvent's message is <>
  905.                 noErr. Returns NIL. }
  906.  
  907.                 PROCEDURE TApplication.KeyEventToComponents(VAR info: EventInfo); OVERRIDE;
  908.                 { re-extracts components of an event in a script manager compatible way. }
  909.  
  910.                 FUNCTION TApplication.HandleKeyDownEvent(VAR theEventInfo: EventInfo): TCommand;
  911.                 { Handles key down events. If the command key is down, then this calls CommandKey.
  912.                 Otherwise it calls gTarget.DoKeyCommand. Returns the result of CommandKey or
  913.                 DoKeyCommand. }
  914.  
  915.                 FUNCTION TApplication.HandleMouseDown(VAR theEventInfo: EventInfo): TCommand;
  916.                 { Called when a mouse down occurs; this cases on whereMouseDown and does the right
  917.                 thing. }
  918.  
  919.                 FUNCTION TApplication.TrackMouse(globalMouse, hysteresis: Point;
  920.                                                  theCommand: TCommand): TCommand;
  921.  
  922.                 { Responsible for mouse tracking. }
  923.  
  924.                 FUNCTION TApplication.HandleMouseUp(VAR theEventInfo: EventInfo): TCommand;
  925.                 { Sets gLastUpTime. Returns NIL. }
  926.  
  927.                 FUNCTION TApplication.HandleSystemEvent(VAR theEventInfo: EventInfo): TCommand;
  928.                 { Handles "system" events, in particular suspend/resume events and mouse moved
  929.                 events. Calls RegainControl if switching in, AboutToLoseControl if switching out,
  930.                 or TrackCursor if it is a mouse-moved event. Returns NIL. }
  931.  
  932.                 FUNCTION TApplication.HandleUpdateEvent(VAR theEventInfo: EventInfo): TCommand;
  933.                 { Handles window update events. Calls UpdateEvent for the window indicate by the
  934.                 event, and returns NIL. }
  935.  
  936.                 FUNCTION TApplication.IsDeskAccessory(aWMgrWindow: WindowPtr): BOOLEAN;
  937.                 { Returns true if the given Window Manager window is a desk accessory. We assume that
  938.                 if the window has a negative windowKind then it is a desk accessory. }
  939.  
  940.                 PROCEDURE TApplication.OpenDeskAccessory(deskAccName: Str255);
  941.                 { Attempts to open the desk accessory whose name is deskAccName. Called from
  942.                 TApplication.MenuEvent when an Apple menu item is chosen, and the item has a
  943.                 negative command number. }
  944.  
  945.                 PROCEDURE TApplication.PollEvent(allowApplicationToSleep: BOOLEAN);
  946.                 { Polls for events calling Idle before waitNextEvent if there are no events pending
  947.                 and the application is allowed to go to sleep (kAllowApplicationToSleep),
  948.                 calls HandleEvent with the event, if there is one. and then idles if necessary. }
  949.  
  950.                 PROCEDURE TApplication.Run;
  951.                 { HandleFinderRequest, and if not finder printing, call MainEventLoop }
  952.  
  953.                 PROCEDURE TApplication.UpdateAllWindows;
  954.                 { Process all update events in the queue. }
  955.  
  956.                 FUNCTION TApplication.InModalState: BOOLEAN;
  957.                 { Returns true if the front window is modal. }
  958.  
  959.                 FUNCTION TApplication.InModalMenuState: BOOLEAN;
  960.                 { Returns true if the front window does not allow menu commands. }
  961.  
  962.                 PROCEDURE TApplication.ReportEvent(VAR theEvent: EventRecord);
  963.                 { Displays information about an event to the debugging window. }
  964.  
  965.                 { Target and Cohandlers }
  966.                 PROCEDURE TApplication.InstallCohandler(aCohandler: TEvtHandler;
  967.                                                         addIt: BOOLEAN);
  968.                 { Used to add (addIt = TRUE) or delete (addIt = FALSE) a cohandler to/from the global
  969.                 list of cohandlers }
  970.  
  971.                 FUNCTION TApplication.GetFrontWindow: TWindow;
  972.                 { Returns the window object reference for the frontmost application window (whether
  973.                 active or not. Returns nil if the FrontWindow window is not a window object }
  974.  
  975.                 FUNCTION TApplication.GetActiveWindow: TWindow;
  976.                 { Returns the window object reference for the active application window.  Returns nil
  977.                 if the FrontWindow window is not a window object }
  978.  
  979.                 PROCEDURE TApplication.SetTarget(newTarget: TEvtHandler);
  980.                 { Sets the current target (the head of the target chain) for the application. }
  981.  
  982.                 { Finder Requests }
  983.                 FUNCTION TApplication.CanOpenDocument(itsCmdNumber: CmdNumber;
  984.                                                       VAR anAppFile: AppFile): BOOLEAN;
  985.                 { Simulates the filtering done by Std File; this is only called when opening/printing
  986.                 documents from the finder; when using Std File, Std File does the filtering. }
  987.  
  988.                 PROCEDURE TApplication.HandleFinderRequest;
  989.                 { Gets the info from the finder about what files to open/print and opens/prints them.
  990.                 }
  991.  
  992.                 { Opening / Printing Documents }
  993.                 FUNCTION TApplication.AlreadyOpen(fileName: Str255;
  994.                                                   volRefnum: INTEGER): TDocument;
  995.                 { Given a name/volRefnum, if that document is already opened, returns the TDocument.
  996.                 Otherwise returns NIL. }
  997.  
  998.                 FUNCTION TApplication.ChooseDocument(itsCmdNumber: CmdNumber;
  999.                                                      VAR anAppFile: AppFile): BOOLEAN;
  1000.                 { Call this to make a Std File Get call; returns TRUE is user selected a file. }
  1001.  
  1002.                 FUNCTION TApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument;
  1003.                 { Must be overridden. Based on itsCmdNumber create a document object of the
  1004.                 appropriate kind. }
  1005.  
  1006.                 FUNCTION TApplication.KindOfDocument(itsCmdNumber: CmdNumber;
  1007.                                                      itsAppFilePtr: AppFilePtr): CmdNumber;
  1008.                 { Given a cmd number and a specification of the file, return the cmd number to pass
  1009.                 to DoMakeDocument that indicates the type of document to make; Default is to return
  1010.                 itsCmdNumber. If you have multiple document types, a good convention is to return
  1011.                 the cmd numbers assigned to create new documents of each kind. itsAppFilePtr will be
  1012.                 NIL if we are creating a brand new document, rather than opening an existing
  1013.                 document. }
  1014.  
  1015.                 PROCEDURE TApplication.OpenNew(itsCmdNumber: CmdNumber);
  1016.                 { Called when the application is opened (itsCmdNumber = cFinderNew), or when NEW is
  1017.                 chosen from menu (itsCmdNumber = cNew). If you do not want to create a new document
  1018.                 when the user opens the application, override this and do nothing if itsCmdNumber =
  1019.                 cFinderNew. }
  1020.  
  1021.                 PROCEDURE TApplication.OpenOld(itsOpenCmd: CmdNumber;
  1022.                                                anAppFile: AppFile);
  1023.                 { Called when opening an existing document from finder (itsCmdNumber = cFinderOpen)
  1024.                 or if OPEN is chosen from menu (itsCmdNumber = cOpen). }
  1025.  
  1026.                 FUNCTION TApplication.PrintDocument(anAppFile: AppFile): BOOLEAN;
  1027.                 { Called to print a document from the finder. Returns TRUE if the user did not cancel
  1028.                 printing of the rest of the documents. }
  1029.  
  1030.                 PROCEDURE TApplication.SFGetParms(itsCmdNumber: CmdNumber;
  1031.                                                   VAR dlgID: INTEGER;
  1032.                                                   VAR where: Point;
  1033.                                                   VAR fileFilter, dlgHook, filterProc: ProcPtr;
  1034.                                                   typeList: TypeListHandle);
  1035.                 { Called to return all the parameters that should be passed to SFGetFile; when
  1036.                 called, typeList is a valid handle to a 0-length block. Defaults to
  1037.                 dlgID = getDlgID;
  1038.                 where = (100, 100);
  1039.                 fileFilter = NIL;
  1040.                 dlgHook = NIL;
  1041.                 filterProc = NIL;
  1042.                 typeList = list of just the main file type supported by the application. (If type
  1043.                 list ends up with nothing in it, then all file types are supported. }
  1044.  
  1045.                 { Termination }
  1046.                 PROCEDURE TApplication.Close;
  1047.                 { Called when the user chooses Quit from the menu, and tries to save all the open
  1048.                 documents. If all succeed the application terminates. Signals Failure with error =
  1049.                 noErr and message = msgCancelled if user cancels }
  1050.  
  1051.                 { Hierarchy }
  1052.                 PROCEDURE TApplication.AddDocument(aNewDocument: TDocument);
  1053.                 { Add another document to my list of documents, and make it the current one }
  1054.  
  1055.                 PROCEDURE TApplication.AddFreeWindow(aWindow: TWindow);
  1056.                 { Add the window to the free-window list }
  1057.  
  1058.                 PROCEDURE TApplication.DeleteDocument(docToDelete: TDocument);
  1059.                 { Delete a document from my list of documents }
  1060.  
  1061.                 PROCEDURE TApplication.DeleteFreeWindow(windowToDelete: TWindow);
  1062.                 { Delete a window from my list of free windows }
  1063.  
  1064.                 PROCEDURE TApplication.EachFreeWindow(PROCEDURE
  1065.                                                       DoToWindow(aWindow: TWindow));
  1066.                 { Perform DoToWindow on each TWindow object in the list gFreeWindowList }
  1067.  
  1068.                 PROCEDURE TApplication.ForAllDocumentsDo(PROCEDURE
  1069.                                                          DoToDoc(aDocument: TDocument));
  1070.                 { Perform the given procedure on all open documents currently owned by the
  1071.                 application }
  1072.  
  1073.                 PROCEDURE TApplication.ForAllWindowsDo(PROCEDURE
  1074.                                                        DoToWind(aWindow: TWindow));
  1075.                 { Perform the given procedure on all windows known to the application, both
  1076.                 document and free windows. }
  1077.  
  1078.                 { Window Manager Windows }
  1079.                 PROCEDURE TApplication.SelectWMgrWindow(aWMgrWindow: WindowPtr);
  1080.                 { "Selects" aWMgrWindow by calling the toolbox routine SelectWindow. When any window
  1081.                 is selected, it goes through here. We never call SelectWindow directly.}
  1082.  
  1083.                 FUNCTION TApplication.GetRsrcWindow(storage: Ptr;
  1084.                                                     rsrcId: INTEGER;
  1085.                                                     VAR isResizable,
  1086.                                                     isClosable: BOOLEAN): WindowPtr;
  1087.                 { Get a Window Manger window resource whose resource id is rsrId. Return isResizable
  1088.                 and isClosable based upon the 'WIND' resource. }
  1089.  
  1090.                 FUNCTION TApplication.WMgrToWindow(aWMgrWindow: WindowPtr): TWindow;
  1091.                 { Returns the window object that represents the given Window Manager window, or NIL
  1092.                 if there is no window object. }
  1093.  
  1094.                 { Idle Events }
  1095.                 PROCEDURE TApplication.Idle(phase: IdlePhase);
  1096.                 { Parcels out idle time to the DoIdle method in the target and cohandler chains of
  1097.                 TEvtHandlers. If your application needs to do something at idle time then override
  1098.                 DoIdle instead of this method. }
  1099.  
  1100.                 { Cursor }
  1101.                 FUNCTION TApplication.TrackCursor: BOOLEAN;
  1102.                 { Returns true if the cursor is set by a view. Otherwise the cursor is set to an
  1103.                 arrow and TrackCursor returns false.}
  1104.  
  1105.                 { Keyboard events }
  1106.                 FUNCTION TApplication.DoKeyCommand(ch: Char;
  1107.                                                    aKeyCode: INTEGER;
  1108.                                                    VAR info: EventInfo): TCommand; OVERRIDE;
  1109.                 { Handle keydown events. }
  1110.  
  1111.                 { Menu Events }
  1112.                 FUNCTION TApplication.DoCommandKey(ch: Char;
  1113.                                                    VAR info: EventInfo): TCommand; OVERRIDE;
  1114.                 { Called when a keyDown event is received and the command key is down. }
  1115.  
  1116.                 FUNCTION TApplication.MenuEvent(menuItem: LONGINT): TCommand;
  1117.                 { Given a value returned by MenuKey or MenuSelect, figure out the command number that
  1118.                 was chosen, have the application create a command object, and return it. }
  1119.  
  1120.                 PROCEDURE TApplication.SetUndoText(cmdDone: BOOLEAN;
  1121.                                                    aCmdNumber: CmdNumber);
  1122.                 { Called to setup the Undo menu item; if cmdDone is TRUE it reads Undo, otherwise it
  1123.                 reads Redo. aCmdNumber indicates the command that goes after the Undo/Redo. }
  1124.  
  1125.                 PROCEDURE TApplication.SetupTheMenus;
  1126.                 { Initiates the process of enabling & checking menu items. }
  1127.  
  1128.                 { Opening and Closing Windows }
  1129.                 PROCEDURE TApplication.CloseWMgrWindow(aWMgrWindow: WindowPtr);
  1130.                 { Called when user closes a window either with a menu item or with a GoAway box.
  1131.                 Signals Failure with error = noErr and message = msgCancelled if user cancels }
  1132.  
  1133.                 { Command Management }
  1134.                 PROCEDURE TApplication.CommitLastCommand; OVERRIDE;
  1135.                 { Commits the last command by calling its Commit method. }
  1136.  
  1137.                 FUNCTION TApplication.GetLastCommand: TCommand; OVERRIDE;
  1138.                 { Returns the last undoable command.  The command returned is not yet committed.}
  1139.  
  1140.                 FUNCTION TApplication.GetNextCommand: TCommand; OVERRIDE;
  1141.                 { Returns a previously posted command.    Nil if there are no queued commands.}
  1142.  
  1143.                 PROCEDURE TApplication.PerformCommand(command: TCommand); OVERRIDE;
  1144.                 { Performs the given command taking care of UNDO/REDO and clipboard related details.
  1145.                 Tracks the command first, if necessary.
  1146.                 This DOES NOT check to see if command is NIL. }
  1147.  
  1148.                 PROCEDURE TApplication.PostCommand(command: TCommand); OVERRIDE;
  1149.                 { Called to post a command to the queue for later execution. }
  1150.  
  1151.                 { Double/Triple Clicks }
  1152.                 FUNCTION TApplication.CountClicks(aPDownEvent: EventRecordPtr;
  1153.                                                   whereMouseDown: INTEGER): INTEGER;
  1154.                 { Called by TApplication.HandleMouseDown. Returns the number of clicks that can be
  1155.                 considered multiple clicks (e.g. if it returns 1 the mouse down should be treated
  1156.                 as a single click, or possibly the first click of a multi-click sequence. If it
  1157.                 returns 2 the click should be considered a double-click, etc. A click is considered
  1158.                 part of a multi-click sequence if the mouse down was within the proper time range
  1159.                 of the previous mouse up, and was within the proper number of pixels of the last
  1160.                 mouse down. TApplication.HandleMouseDown sets theClickCount of its EventInfo record
  1161.                 to the result of this function. aPDownEvent is a pointer to the mouse down event.
  1162.                 whereMouseDown is the result of FindWindow on the event. }
  1163.  
  1164.                 { Command Handlers }
  1165.                 FUNCTION TApplication.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  1166.                 { Handles the application specific menu commands. }
  1167.  
  1168.                 PROCEDURE TApplication.DoSetupMenus; OVERRIDE;
  1169.  
  1170.                 { Clipboard stuff }
  1171.  
  1172.                 PROCEDURE TApplication.AbandonUndoClipboard;
  1173.                 { Called when the undo clipboard is no longer needed. Calls
  1174.                 gClipUndoView.FreeFromClipboard and sets gClipUndoView to NIL. }
  1175.  
  1176.                 PROCEDURE TApplication.AboutToLoseControl(convertClipboard: BOOLEAN);
  1177.                 { Called when about to activate a Desk Accessory, switch out to another application,
  1178.                 or Terminate. convertClipboard is generally true, except it will be FALSE if we get
  1179.                 a Swticher event that does not require Clipboard conversion }
  1180.  
  1181.                 PROCEDURE TApplication.AbsorbScrapStuff;
  1182.                 { Called to retrieve the current InfoScrap record from low memory. This will be used
  1183.                 to determine if the scrap has changed. }
  1184.  
  1185.                 PROCEDURE TApplication.CheckDeskScrap;
  1186.                 { Checks to see if the desk scrap has changed by calling AbsorbScrapStuff and
  1187.                 comparing the current scrap change count with the previous change count. If the
  1188.                 scrap has changed, then the current clipboard becomes the undo clipboard and
  1189.                 ReadFromDeskScrap is called to read in the new desk scrap. }
  1190.  
  1191.                 PROCEDURE TApplication.ClaimClipboard(clipView: TView);
  1192.                 { Makes clipView the new view displayed by the Clipboard. Typically called by a Cut
  1193.                 or Copy command. }
  1194.  
  1195.                 FUNCTION TApplication.GetDataToPaste(aDataHandle: Handle;
  1196.                                                      VAR dataType: ResType): LONGINT;
  1197.                 { Returns the number of bytes in the paste data. Will signal Failure if it gets an
  1198.                 error. }
  1199.  
  1200.                 PROCEDURE TApplication.LaunchClipboard;
  1201.                 { Called by TApplication.Run, before the main event loop. }
  1202.  
  1203.                 FUNCTION TApplication.MakeClipboardWindow: TWindow;
  1204.                 { Called by TApplication.IApplication to make the clipboard window and associated
  1205.                 frame(s). clipView is the view to be initially installed in the clipboard--it is
  1206.                 gClipOrphanage. }
  1207.  
  1208.                 PROCEDURE TApplication.ReadFromDeskScrap;
  1209.                 { Called at launch and when the desk scrap changes. Calls
  1210.                 TApplication.MakeViewForAlienClipboard, then ClaimClipboard }
  1211.  
  1212.                 FUNCTION TApplication.MakeViewForAlienClipboard: TView;
  1213.                 { Returns gClipOrphanage, which is capable of displaying scrap of type TEXT or PICT.
  1214.                 Override this to create a view to handle other types of scrap data. }
  1215.  
  1216.                 PROCEDURE TApplication.RegainControl(checkClipboard: BOOLEAN);
  1217.                 { Called when switching in or when leaving a desk accessory }
  1218.  
  1219.                 PROCEDURE TApplication.SetClipView(clipView: TView);
  1220.                 { Installs the given view into the clipboard window. }
  1221.  
  1222.                 PROCEDURE TApplication.SwapClipViews;
  1223.                 { Swaps the undo clipboard view with the current clipboard view. Used during an Undo
  1224.                 or Redo. }
  1225.  
  1226.                 { Debugging }
  1227.                 PROCEDURE TApplication.IdentifySoftware; OVERRIDE;
  1228.                 { Writes out to the debug window the current version of MacApp® , UObject and UDebug.
  1229.                 }
  1230.  
  1231.                 { Error Alerts }
  1232.  
  1233.                 PROCEDURE TApplication.Beep(duration: INTEGER);
  1234.                 { Call this method when you want to beep at the user. Sound manager users may have to
  1235.                 override this method to integrate its functionality in with your application }
  1236.  
  1237.                 PROCEDURE TApplication.ShowError(error: OSerr;
  1238.                                                  message: LONGINT);
  1239.                 { Calls ErrorAlert to display an error alert. }
  1240.  
  1241.                 PROCEDURE TApplication.SpaceIsLow;
  1242.                 { Called when space is low, at intervals of kLowSpaceInterval ticks. Displays an
  1243.                 alerting informing the user that memory space is low. Override this if you wish to
  1244.                 take more appropriate action. }
  1245.  
  1246.                 { Miscellaneous }
  1247.  
  1248.                 PROCEDURE TApplication.DoShowAboutApp;
  1249.                 { Called to show the "About the App" information }
  1250.  
  1251.                 PROCEDURE TApplication.InvalidateFocus;
  1252.                 { Called to indicate that a view is unfocused when you don't know which view
  1253.                 was focused. }
  1254.  
  1255.                 PROCEDURE TApplication.InvalidateCursorRgn;
  1256.                 { Indicates that the cursor rgn that is used to determine when MultiFinder™ should
  1257.                 wake up your application and tell you the mouse moved is invalid and must be
  1258.                 recomputed.  When not using MultiFinder™ the region is used to determine when to
  1259.                 give all the subviews a chance to set the cursor. }
  1260.  
  1261.                 PROCEDURE TApplication.ActivateBusyCursor(entering: BOOLEAN);
  1262.                 { Called when the busy cursor mechanism should be activated or deactivated. }
  1263.  
  1264.                 END;
  1265.  
  1266. {--------------------------------------------------------------------------------------------------}
  1267.             TDocument            = OBJECT (TEvtHandler)    { Corresponds to a Finder document. Manages
  1268.                                                          document data in files and in main memory.
  1269.                                                          }
  1270.                 fWindowList:        TList;                { list of windows belonging to this document
  1271.                                                          }
  1272.                 fViewList:            TList;                { list of views belonging to document }
  1273.                 fDocPrintHandler:    TPrintHandler;        { the object to be told to PRINT or
  1274.                                                          DoSetUpMenus when 'Print', 'Print One', or
  1275.                                                          'Page Setup…' is selected from the menu
  1276.                                                          while this is the active document. }
  1277.  
  1278.                 fChangeCount:        LONGINT;            { master count of changes since last Save }
  1279.                 fSavePrintInfo:     BOOLEAN;            { if TRUE for a document saved on disk, the
  1280.                                                          'print info' record of the
  1281.                                                          fDocPrintHandler will be written out to
  1282.                                                          the data fork before other writing takes
  1283.                                                          place }
  1284.                 fSharePrintInfo:    BOOLEAN;            { if TRUE, then all printHandlers associated
  1285.                                                          with views belonging to the same document
  1286.                                                          will share the same 'print info' record }
  1287.                 fPrintInfo:         Handle;             { if non-NIL, this is a handle to a 120-byte
  1288.                                                          'print info' record }
  1289.  
  1290.                 fTitle:             StringHandle;        { file name }
  1291.                 fFileType:            OSType;             { file type }
  1292.                 fCreator:            OSType;             { creator ID }
  1293.                 fVolRefNum:         INTEGER;            { volume refNum }
  1294.                 fModDate:            LONGINT;            { file mod date when last read/saved }
  1295.                 fReopenAlert:        BOOLEAN;            { whether to give an alert if user reopens
  1296.                                                          doc }
  1297.                 fSaveExists:        BOOLEAN;            { whether a disk file representing this
  1298.                                                          document exists }
  1299.                 fCommitOnSave:        BOOLEAN;            { commit the last command before saving the
  1300.                                                          document, if it affected the document.
  1301.                                                          This defaults to TRUE, but carefully
  1302.                                                          written applications could set this FALSE.
  1303.                                                          }
  1304.                 fUsesDataFork:        BOOLEAN;            { whether the document uses the data fork of
  1305.                                                          the file }
  1306.                 fUsesRsrcFork:        BOOLEAN;            { whether the document uses the rsrc fork of
  1307.                                                          the file }
  1308.                 fDataOpen:            BOOLEAN;            { whether the data fork should be open all
  1309.                                                          the time }
  1310.                 fRsrcOpen:            BOOLEAN;            { whether the resources fork be open all the
  1311.                                                          time }
  1312.                 fDataPerm:            INTEGER;            { permission to use for reading data fork }
  1313.                 fRsrcPerm:            INTEGER;            { permission to use for reading the rsrc
  1314.                                                          fork }
  1315.                 fDataRefnum:        INTEGER;            { refnum; valid only if data fork is left
  1316.                                                          open }
  1317.                 fRsrcRefnum:        INTEGER;            { refnum; valid only if resource fork is
  1318.                                                          left open }
  1319.                                                        { these will be -1 if the fork is
  1320.                                                         not open or if the corresponding
  1321.                                                         fXXXOpen flag is FALSE }
  1322.                 fSaveInPlace:        SIPChoice;            { how to save files in place (if desired) }
  1323.  
  1324.                                 { Init & Free }
  1325.                 PROCEDURE TDocument.IDocument(itsFileType, itsCreator: OSType;
  1326.                                               usesDataFork, usesRsrcFork: BOOLEAN;
  1327.                                               keepsDataOpen, keepsRsrcOpen: BOOLEAN);
  1328.                 { Initialization method for TDocument. }
  1329.  
  1330.                 PROCEDURE TDocument.Free; OVERRIDE;
  1331.                 { This does not call FreeData by default, since you may need to control the order in
  1332.                 which things are freed. Your override of TDocument.Free can call FreeData if
  1333.                 convenient. }
  1334.  
  1335.                 PROCEDURE TDocument.FreeData;
  1336.                 { Called when a document is reverted, in order to free it's data objects. You may
  1337.                 also wish to call this from you document's Free method, if convenient. }
  1338.  
  1339.                 PROCEDURE TDocument.FreeFromClipboard;
  1340.                 { Called to free a Clipboard document.Simply calls Free. }
  1341.  
  1342.                 PROCEDURE TDocument.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  1343.                 { Called by the Inspector to get the name of this class. }
  1344.  
  1345.                 PROCEDURE TDocument.Fields(PROCEDURE
  1346.                                            DoToField(fieldName: Str255;
  1347.                                                      fieldAddr: Ptr;
  1348.                                                      fieldType: INTEGER)); OVERRIDE;
  1349.                 { Called by the Inspector and the Debugger to display the contents of this class's
  1350.                 fields. }
  1351.  
  1352.                 { Opening / Printing Documents }
  1353.                 PROCEDURE TDocument.DoInitialState;
  1354.                 { Called for 'New', 'Revert' to blank, Open Tool. Default is to do nothing; You may
  1355.                 need to do further initialization that you would not do in case of an Open… }
  1356.  
  1357.                 PROCEDURE TDocument.DoMakeWindows;
  1358.                 { Should take the views created by DoMakeViews and create windows and frames to
  1359.                 display them. }
  1360.  
  1361.                 PROCEDURE TDocument.DoMakeViews(forPrinting: BOOLEAN);
  1362.                 { Create all necessary views for this document (based on forPrinting flag) and store
  1363.                 into fields of your document. The document will then be sent either DoMakeWindows
  1364.                 or Print. }
  1365.  
  1366.                 PROCEDURE TDocument.DoRead(aRefNum: INTEGER;
  1367.                                            rsrcExists, forPrinting: BOOLEAN);
  1368.                 { rsrcExists indicates whether the document has a resource fork opened or not; it is
  1369.                 FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
  1370.                 making a copy of the document (vs. a regular Save or Save As…); disk-based
  1371.                 documents (especially) might optimize their behavior if this is TRUE. The default
  1372.                 behaviour is to just read the printinfo from the document's data-fork (useful huh?)
  1373.                 }
  1374.  
  1375.                 PROCEDURE TDocument.DoWrite(aRefNum: INTEGER;
  1376.                                             makingCopy: BOOLEAN);
  1377.                 { rsrcExists indicates whether the document has a resource fork opened or not; it is
  1378.                 FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
  1379.                 making a copy of the document (vs. a regular Save or Save As…); disk-based
  1380.                 documents (especially) might optimize their behavior if this is TRUE. The default
  1381.                 behaviour is to just write the printinfo to the document's data-fork (useful huh?)}
  1382.  
  1383.                 FUNCTION TDocument.HandlesPrintingCommands: BOOLEAN; OVERRIDE;
  1384.                 { By defualt returns FALSE. }
  1385.  
  1386.                 FUNCTION TDocument.OpenAFile(name: Str255;
  1387.                                              volRefnum: INTEGER;
  1388.                                              openData, openRsrc: BOOLEAN;
  1389.                                              dataPerm, rsrcPerm: INTEGER;
  1390.                                              VAR dataRefnum, rsrcRefnum: INTEGER): OSerr;
  1391.                 { Called from ReadFromFile to open the document's data and/or resource forks.}
  1392.  
  1393.                 PROCEDURE TDocument.OpenAgain(itsCmdNumber: CmdNumber;
  1394.                                               openingDoc: TDocument);
  1395.                 { Called if the user tries to open the same document twice. openingDoc will be the
  1396.                 document object being opened. Default brings SELF to the front and calls
  1397.                 Failure(noErr, 0), which will abort opening the document. (The goal is to prevent
  1398.                 the user from having 2 copies of the same document open, in which case they could
  1399.                 make incompatible changes to both.) You might override this if you want to open a
  1400.                 second window on the same document. In the ideal case, you should make both windows
  1401.                 display exactly the same data, and changes made to one should be reflected in the
  1402.                 other. You could also override this to create a read-only copy of the document. }
  1403.  
  1404.                 PROCEDURE TDocument.ReadFromFile(VAR anAppFile: AppFile;
  1405.                                                  forPrinting: BOOLEAN);
  1406.                 { Called to read an existing file for display or printing. If anAppFile.fName = ''
  1407.                 THEN we read from the file specified in the instance variables instead of the
  1408.                 parameter, and the parameter will be updated to match the document. }
  1409.  
  1410.                 PROCEDURE TDocument.ShowWindows;
  1411.                 { Called when opening the document initially; default is to call OpenWindow for all
  1412.                 windows that have fFlags.openInitially TRUE }
  1413.  
  1414.                 PROCEDURE TDocument.UntitledName(VAR noName: Str255);
  1415.                 { Called to supply a name for an untitled document. If this returns '' then the
  1416.                 windows are not renamed from the value specified in their titles. }
  1417.  
  1418.                 { Saving Documents }
  1419.                 PROCEDURE TDocument.AboutToSave(itsCmd: CmdNumber;
  1420.                                                 VAR newName: Str255;
  1421.                                                 VAR newVolRefnum: INTEGER;
  1422.                                                 VAR makingCopy: BOOLEAN);
  1423.                 { Called right after the SFPutFile (if any) and before deciding between SaveViaTemp &
  1424.                 SaveInPlave. Applications can use the name in an alert and/or modify the makingCopy
  1425.                 parameter if they do not want to have the document renamed. }
  1426.  
  1427.                 PROCEDURE TDocument.DoNeedDiskSpace(VAR dataForkBytes, rsrcForkBytes: LONGINT);
  1428.                 { Bytes required to store SAVE file(s) on disk. When called, both parameters are set
  1429.                 to 0 for you. }
  1430.  
  1431.                 PROCEDURE TDocument.FreeFile;
  1432.                 { Called to free in memory data associated with the currently opened document. The
  1433.                 default is to call CloseFile(fDataRefnum, fRsrcRefnum) if fDataOpen OR fRsrcOpen. }
  1434.  
  1435.                 FUNCTION TDocument.GetSaveInfo(itsCmdNumber: CmdNumber;
  1436.                                                copyFInfo: BOOLEAN;
  1437.                                                VAR cInfo: CInfoPBRec): BOOLEAN;
  1438.                 { Called to get the desired file info for saving the file. Default copies the info
  1439.                 from the current file if fSaveExists AND copyFInfo, otherwise it just sets the file
  1440.                 type and creator based on the fields of SELF. If an error occurs calling the file
  1441.                 system, the cInfo record will not be filled in. Returns TRUE if it successfully
  1442.                 gets the info from the file. }
  1443.  
  1444.                 PROCEDURE TDocument.GetTempName(VAR fileName: Str255);
  1445.                 { Return a temporary name for saving the file. The filename is constructed in two
  1446.                 parts: the first part is the document's name, or the application's name if the
  1447.                 document is untitled. The second part, appended to the first part, is a pseudo-
  1448.                 random number based on the tick count and number of seconds since boot. }
  1449.  
  1450.                 PROCEDURE TDocument.MakeNewCopy(makingCopy: BOOLEAN;
  1451.                                                 validFInfo: BOOLEAN;
  1452.                                                 VAR cInfo: CInfoPBRec);
  1453.                 { Creates a brand new copy of the document in the file specified by cInfo. The name,
  1454.                 volume refnum, file type, and creator must be specified in cInfo. The other info
  1455.                 fields of cInfo are used only if makingCopy is FALSE. makingCopy is TRUE if this
  1456.                 save is making a copy of the document (vs. a regular Save or Save As…) Caller is
  1457.                 responsible for calling FlushVol after this. }
  1458.  
  1459.                 FUNCTION TDocument.PoseSaveDialog: INTEGER;
  1460.                 { If the document has been changed (fChangeCount > 0), then the user is asked to save
  1461.                 the document. PoseSaveDialog returns cancel, kYesButton or kNoButton, depending on
  1462.                 the button chosen by the user. If the document has not been changed then kNoButton
  1463.                 is returned. }
  1464.  
  1465.                 PROCEDURE TDocument.RequestFileName(itsCmdNumber: CmdNumber;
  1466.                                                     makingCopy: BOOLEAN;
  1467.                                                     VAR fileName: Str255;
  1468.                                                     VAR volRefnum: INTEGER);
  1469.                 { Asks the user for a filename for the document. Calls TDocument.SFPutParms and then
  1470.                 SFPPutFile. Fails if the user clicks the Cancel button to end the put file dialog.
  1471.                 }
  1472.  
  1473.                 FUNCTION TDocument.GetChangeCount: LONGINT;
  1474.                 { Gets the document change count }
  1475.  
  1476.                 PROCEDURE TDocument.SetChangeCount(newChangeCount: LONGINT);
  1477.                 { Sets the document change count }
  1478.  
  1479.                 PROCEDURE TDocument.Save(itsCmdNumber: CmdNumber;
  1480.                                          askForFilename, makingCopy: BOOLEAN);
  1481.                 { Try to save the document to disk; If askForFilename, put up a Std File box; If
  1482.                 makingCopy, then this is for the Save a Copy In command, so we do not rename the
  1483.                 document. This method calls FlushVol (which takes care of the requirements of
  1484.                 MakeNewCopy, SaveInPlace, and SaveViaTemp. }
  1485.  
  1486.                 PROCEDURE TDocument.SaveAgain(itsCmdNumber: CmdNumber;
  1487.                                               makingCopy: BOOLEAN;
  1488.                                               savingDoc: TDocument);
  1489.                 { Called when the user tries to Save As… or Save a Copy In… and specifies the name of
  1490.                 a document that is already opened. The default case calls Failure(errSaveAgain,
  1491.                 msgSaveFailed) to display an error. (The goal is to prevent the user from having 2
  1492.                 copies of the same document open, in which case they might make incompatible
  1493.                 changes to both copies.) savingDoc is the document being saved }
  1494.  
  1495.                 PROCEDURE TDocument.SavedOn(VAR fileName: Str255;
  1496.                                             volRefnum: INTEGER);
  1497.                 { Called when a save successfully completes and we are switching to the new file
  1498.                 (ie., not a Save a Copy In…). }
  1499.  
  1500.                 PROCEDURE TDocument.SaveInPlace(itsCmdNumber: CmdNumber;
  1501.                                                 makingCopy, copyFInfo: BOOLEAN;
  1502.                                                 VAR fileName: Str255;
  1503.                                                 volRefnum: INTEGER);
  1504.                 { Called to save a document in place. Default is to delete the existing file if NOT
  1505.                 (fDataOpen OR fRsrcOpen). If you have disk based document, you have to decide
  1506.                 whether to allow saving in place. makingCopy is TRUE if this save is making a copy
  1507.                 of the document (vs. a regular Save or Save As…) copyFInfo is TRUE if the file
  1508.                 information should be copied to the new file Caller is responsible for calling
  1509.                 FlushVol after this. }
  1510.  
  1511.                 PROCEDURE TDocument.SaveViaTemp(itsCmdNumber: CmdNumber;
  1512.                                                 makingCopy, copyFInfo: BOOLEAN;
  1513.                                                 VAR fileName: Str255;
  1514.                                                 volRefnum: INTEGER);
  1515.                 { Called to save the document by creating a temporary copy of the file and renaming
  1516.                 it. MacApp uses this method except when there is not enough disk space available.
  1517.                 makingCopy is TRUE if this save is making a copy of the document (vs. a regular
  1518.                 Save or Save As…) copyFInfo is TRUE if the file information should be copied to the
  1519.                 new file Caller is responsible for calling FlushVol after this. }
  1520.  
  1521.                 PROCEDURE TDocument.SFPutParms(itsCmdNumber: CmdNumber;
  1522.                                                VAR dlgID: INTEGER;
  1523.                                                VAR where: Point;
  1524.                                                VAR defaultName, prompt: Str255;
  1525.                                                VAR dlgHook, filterProc: ProcPtr);
  1526.                 { Called to return all the parameters that should be passed to
  1527.                 SFPutFile. Defaults to
  1528.                 dlgID = putDlgID;
  1529.                     where = (100, 100);
  1530.                     defaultName not changed;
  1531.                     prompt gotten from resource file;
  1532.                     dlgHook = NIL;
  1533.                     filterProc = NIL. }
  1534.  
  1535.                 { Closing Documents }
  1536.                 PROCEDURE TDocument.Close;
  1537.                 { Close a document and free it. Signals Failure with error = noErr and message =
  1538.                 msgCancelled if user cancels. ??? NOTE: Must never be called for a document related
  1539.                 to a view in the Clipboard. }
  1540.  
  1541.                 { Revert }
  1542.                 PROCEDURE TDocument.Revert;
  1543.                 { IF fSaveExists is TRUE then reverts to the file saved on disk, otherwise merely
  1544.                 resets the print handler and calls doInitialState. Calls FreeData to free any
  1545.                 existing data and commits any currently active command. }
  1546.  
  1547.                 PROCEDURE TDocument.Abandon;
  1548.                 { Called when a document is closed and changes are being abandoned.  For memory based
  1549.                 documents the default behaviour of doing nothing is OK.  For disk based documents that
  1550.                 change the original copy this is the place to override to put back the original
  1551.                 contents if you still have it available somewhere (a scratch file?) }
  1552.  
  1553.                 PROCEDURE TDocument.ShowReverted;
  1554.                 { Called after Revert to show brand new document; default tells each view to
  1555.                 ShowReverted }
  1556.  
  1557.                 { Miscellaneous }
  1558.                 PROCEDURE TDocument.CheckDiskFile(rsrcId, rsrcIndex: INTEGER;
  1559.                                                   reverting: BOOLEAN);
  1560.                 { Check to see if the disk file has changed. If so put up alert phFileChanged after
  1561.                 setting ^0 to fTitle and ^1 to the string specified by the rsrcId and rsrcIndex. If
  1562.                 user cancels, signal Failure(noErr, msgCancelled). If reverting is TRUE, then I/O
  1563.                 errors and nonmatching file types will cause a Failure. Otherwise, this is a Save
  1564.                 and any I/O errors and nonmatching file type will be ignored. }
  1565.  
  1566.                 FUNCTION TDocument.DiskFileChanged(checkType: BOOLEAN): OSerr;
  1567.                 { Returns noErr if fSaveExists is FALSE or if the file's modification date matches
  1568.                 fModDate. If checkType is TRUE then returns errFTypeChanged if the file type has
  1569.                 changed. If the file exists but with a different modification date, returns
  1570.                 errFileChanged. }
  1571.  
  1572.                 PROCEDURE TDocument.SetTitle(aTitle: Str255);
  1573.                 { Sets SELF.fTitle to aTitle and calls SetTitleForDoc for each window of the
  1574.                 document. }
  1575.  
  1576.                 { Command Handlers }
  1577.                 FUNCTION TDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  1578.                 { Handles the default menu commands associated with a document and must be overridden
  1579.                 to handle any additional items. }
  1580.  
  1581.                 PROCEDURE TDocument.DoSetupMenus; OVERRIDE;
  1582.                 { Setup the documents menus, this handles the default menus and must be overridden
  1583.                 for any additional items. }
  1584.  
  1585.                 { Hierarchy }
  1586.                 PROCEDURE TDocument.AddView(aView: TView);
  1587.                 { Adds the view to the end of the document's view list. }
  1588.  
  1589.                 PROCEDURE TDocument.AddWindow(aWindow: TWindow);
  1590.                 { Adds the window to the end of the document's window list. }
  1591.  
  1592.                 PROCEDURE TDocument.CloseView(aView: TView);
  1593.                 { Called to close a view or window associated with a document.
  1594.                 Document gets to decide whether to really close the view or not and whether to
  1595.                 close itself or not.  Does nothing if the view is not associated with the doc. }
  1596.  
  1597.                 PROCEDURE TDocument.DeleteView(viewToDelete: TView);
  1598.                 { Deletes the view from the document's view list. }
  1599.  
  1600.                 PROCEDURE TDocument.DeleteWindow(windowToDelete: TWindow);
  1601.                 { Deletes the window from the document's window list. }
  1602.  
  1603.                 PROCEDURE TDocument.ForAllViewsDo(PROCEDURE
  1604.                                                   DoToView(aView: TView));
  1605.                 { Performs DoToView on every view in every window belonging to the document. If you
  1606.                 want to deal with all views belonging to the document use fViewList.Each. }
  1607.  
  1608.                 PROCEDURE TDocument.ForAllWindowsDo(PROCEDURE
  1609.                                                     DoToWind(aWindow: TWindow));
  1610.                 { Perform the supplied proc to each window belonging to the document }
  1611.  
  1612.                 END;
  1613.  
  1614. {--------------------------------------------------------------------------------------------------}
  1615.             ViewTemplateSelector = (ViewType, ViewIncludeAt); { So C++ unions can have names }
  1616.             ViewTemplate        = PACKED RECORD
  1617.                 itsParentID:        IDType;
  1618.                 thisViewID:         IDType;
  1619.                 itsLocation:        VPoint;
  1620.                 itsSize:            VPoint;
  1621.                 itsVSizeDet:        SizeDeterminer;
  1622.                 itsHSizeDet:        SizeDeterminer;
  1623.                 isShown:            BOOLEAN;
  1624.                 isEnabled:            BOOLEAN;
  1625.                 filler:             Byte;
  1626.                 itsSignature:        IDType;             { Resource signature }
  1627.                 CASE ViewTemplateSelector OF
  1628.                     ViewType:
  1629.                         (itsType:             Str255);    { Actually variable length }
  1630.                     ViewIncludeAt:
  1631.                         (includeRsrcID:      INTEGER;
  1632.                          itsSubViewOffset:     VPoint);
  1633.                 END;
  1634.             ViewTemplatePtr     = ^ViewTemplate;
  1635.  
  1636.             ViewResource        = RECORD
  1637.                 numViews:            INTEGER;
  1638.                 theViews:            ViewTemplate;        { Actually, open-ended }
  1639.                 END;
  1640.             ViewRsrcPtr         = ^ViewResource;
  1641.             ViewRsrcHandle        = ^ViewRsrcPtr;         { Preferred }
  1642.             ViewRsrcHndl        = ViewRsrcHandle;        { Left in for compatibility (2.0) }
  1643.  
  1644. {--------------------------------------------------------------------------------------------------}
  1645.             { Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the focus
  1646.             behind MacApp's back. One use is to speed up scrolling (see TScroller). }
  1647.             {$IFC qExperimentalAndUnsupported}
  1648.             FocusRec            = RECORD
  1649.                 printing:            BOOLEAN;
  1650.                 drawingPictScrap:    BOOLEAN;
  1651.                 drawingPictScrapView: TView;
  1652.                 focusedView:        TView;
  1653.                 longOffset:         VPoint;
  1654.                 org:                Point;
  1655.                 port:                GrafPtr;
  1656.                 clip:                RgnHandle;
  1657.                 isValid:            BOOLEAN;        { TRUE if FocusRec is valid }
  1658.                 END;
  1659.             {$EndC}
  1660.  
  1661. {--------------------------------------------------------------------------------------------------}
  1662.             TView                = OBJECT (TEvtHandler)    { Renders an image of a document or other
  1663.                                                          data, and identifies mouse-clicked
  1664.                                                          objects. }
  1665.                 fSuperView:         TView;                { the current superview }
  1666.                 fSubViews:            TList;                { subviews of this view }
  1667.                 fDocument:            TDocument;            { the associated document if any. }
  1668.                 fLocation:            VPoint;             { the location in superview coordinates }
  1669.                 fSize:                VPoint;             { the size of this view }
  1670.                 fSizeDeterminer:    ARRAY [VHSelect] OF SizeDeterminer; { how this view's size is to
  1671.                                                                          be determined }
  1672.                 fHLDesired:         HLState;            { the hilighting that is desired for this
  1673.                                                          view }
  1674.                 fIdentifier:        IDType;             { the ID if any }
  1675.                 fShown:             BOOLEAN;            { is this view to be shown }
  1676.                 fViewEnabled:        BOOLEAN;            { is this view enabled. (does it take
  1677.                                                          clicks/keystrokes }
  1678.                 fPrintHandler:        TPrintHandler;        { the associated print handler if any. }
  1679.                 {$IFC qExperimentalAndUnsupported}
  1680.                 fFocusRec:            FocusRec;            { The cached focus information }
  1681.                 {$EndC}
  1682.  
  1683.                                 { Creation/Destruction Methods }
  1684.  
  1685.                 PROCEDURE TView.IView(itsDocument: TDocument;
  1686.                                       itsSuperView: TView;
  1687.                                       itsLocation: VPoint;
  1688.                                       itsSize: VPoint;
  1689.                                       itsHSizeDet, itsVSizeDet: SizeDeterminer);
  1690.                 { Initializes a view procedurally. }
  1691.  
  1692.                 PROCEDURE TView.IRes(itsDocument: TDocument;
  1693.                                      itsSuperView: TView;
  1694.                                      VAR itsParams: Ptr);
  1695.                 { Initialize aview from a resource template. }
  1696.  
  1697.                 PROCEDURE TView.WRes(theResource: ViewRsrcHndl;
  1698.                                      VAR itsParams: Ptr);
  1699.                 { For writing a view out to a resource. }
  1700.  
  1701.                 PROCEDURE TView.WriteRes(theResource: ViewRsrcHndl;
  1702.                                          VAR itsParams: Ptr);
  1703.                 { For writing a view to a resource works in conjunction with tbe previous method. }
  1704.  
  1705.                 PROCEDURE TView.Free; OVERRIDE;
  1706.                 { Frees its subviews, then if its superview is not NIL removes itself from the
  1707.                 superviews list of subviews and if its document is not NIL removes itself from the
  1708.                 documents list of views. If it has a print handler then it frees it, then calls
  1709.                 inherited Free. }
  1710.  
  1711.                 PROCEDURE TView.FreeFromClipboard;
  1712.                 { If its document is not NIL then calls the document's FreeFromClipboard method,
  1713.                 otherwise calls Free. }
  1714.  
  1715.                 { Coordinate Conversion Methods }
  1716.  
  1717.                 PROCEDURE TView.QDToViewPt(qdPoint: Point;
  1718.                                            VAR viewPt: VPoint);
  1719.                 { Convert a Quickdraw point to a view point. }
  1720.  
  1721.                 PROCEDURE TView.QDToViewRect(qdRect: Rect;
  1722.                                              VAR viewRect: VRect);
  1723.                 { Convert a Quickdraw rect to a view rect. }
  1724.  
  1725.                 FUNCTION TView.ViewToQDPt(viewPt: VPoint): Point;
  1726.                 { Convert a view point to a QuickDraw point. }
  1727.  
  1728.                 PROCEDURE TView.ViewToQDRect(viewRect: VRect;
  1729.                                              VAR qdRect: Rect);
  1730.                 { Convert a view rect to a Quickdraw rect. }
  1731.  
  1732.                 PROCEDURE TView.LocalToSuper(VAR thePoint: VPoint);
  1733.                 { Given a point in local view coordinates, returns the same point in its superview's
  1734.                 coordinate system.}
  1735.  
  1736.                 PROCEDURE TView.SuperToLocal(VAR thePoint: VPoint);
  1737.                 { Given a point in superview coordinates, returns the same point in the view's own
  1738.                 coordinate system. }
  1739.  
  1740.                 PROCEDURE TView.LocalToWindow(VAR thePoint: VPoint);
  1741.                 { Given a point in local view coordinates, returns the same point in its window's (or
  1742.                 most super superview's) coordinate system.}
  1743.  
  1744.                 PROCEDURE TView.WindowToLocal(VAR thePoint: VPoint);
  1745.                 { Given a point in window (or most super superview) coordinates, returns the same
  1746.                 point in the view's own coordinate system. }
  1747.  
  1748.                 { SubView Management Methods }
  1749.  
  1750.                 PROCEDURE TView.EachSubView(PROCEDURE
  1751.                                             DoToSubView(theSubView: TView));
  1752.                 { Iterate over all the views subviews passing each in turn to the procedure
  1753.                 "DoToSubView". }
  1754.  
  1755.                 FUNCTION TView.FirstSubViewThat(FUNCTION
  1756.                                                 TestSubView(theSubView: TView): BOOLEAN): TView;
  1757.                 { Iterate over this views subviews and return the first subview that meets
  1758.                 'TestSubView'. }
  1759.  
  1760.                 FUNCTION TView.LastSubViewThat(FUNCTION
  1761.                                                TestSubView(theSubView: TView): BOOLEAN): TView;
  1762.                 { Iterate over this views subviews and return the last subview that meets
  1763.                 "TestSubView". }
  1764.  
  1765.                 PROCEDURE TView.AddSubView(theSubView: TView);
  1766.                 { Add 'theSubView' to our list of subviews. }
  1767.  
  1768.                 PROCEDURE TView.RemoveSubView(theSubView: TView);
  1769.                 { Remove 'theSubView' from our list of subviews. }
  1770.  
  1771.                 PROCEDURE TView.MakeFirstSubView(theSubView: TView);
  1772.                 { Make 'theSubView ' the first subview in our list. }
  1773.  
  1774.                 PROCEDURE TView.MakeLastSubView(theSubView: TView);
  1775.                 { Make 'theSubView' the last subview in our list. }
  1776.  
  1777.                 FUNCTION TView.CountSubViews: INTEGER;
  1778.                 { Return the number of subviews in our view. }
  1779.  
  1780.                 FUNCTION TView.FindSubView(itsIdentifier: IDType): TView;
  1781.                 { Find subview with identifier 'itsIdentifier' in our list of subviews. }
  1782.  
  1783.                 { Open/Close/Activate Methods }
  1784.  
  1785.                 PROCEDURE TView.Activate(entering: BOOLEAN);
  1786.                 { Focuses and then highlights any current selection before calling all its subviews
  1787.                 to activate themselves. }
  1788.  
  1789.                 PROCEDURE TView.Open;
  1790.                 { Calls each of its subviews to Open themselves. }
  1791.  
  1792.                 PROCEDURE TView.Close;
  1793.                { Commits the last command before calling each of its subviews to Close themselves. }
  1794.  
  1795.                 PROCEDURE TView.BeInScroller(itsScroller: TScroller);
  1796.                 { If 'itsScroller' is not NIL then sets its scroll limits to  its fSize. }
  1797.  
  1798.                 PROCEDURE TView.BeInPort(itsPort: GrafPtr);
  1799.                 { If its print handler is not NIL, calls DoCheckPrinter. Then calls each of its
  1800.                 subviews to BeInPort. }
  1801.  
  1802.                 PROCEDURE TView.ShowReverted;
  1803.                 { First calls AdjustSize before forcing a redraw of the view, then call ShowReverted
  1804.                 for each of its subviews. }
  1805.  
  1806.                 { Choice Handling Methods }
  1807.  
  1808.                 PROCEDURE TView.DoChoice(origView: TView;
  1809.                                          itsChoice: INTEGER); OVERRIDE;
  1810.                 { If its superview is not NIL calls its DoChoice method. }
  1811.  
  1812.                 { Size Methods }
  1813.  
  1814.                 PROCEDURE TView.AdjustSize;
  1815.                 { Calls ComputeSize, if the size has changed resizes itself and then calls
  1816.                 DoPagination so that any page breaks can be recalculated. }
  1817.  
  1818.                 PROCEDURE TView.CalcMinSize(VAR minSize: VPoint);
  1819.                 { Calculate the minimum size of SELF. }
  1820.  
  1821.                 PROCEDURE TView.ComputeSize(VAR newSize: VPoint);
  1822.                 { Called by MacApp®  to get the size of the view computed. }
  1823.  
  1824.                 PROCEDURE TView.Resize(width, height: VCoordinate;
  1825.                                        invalidate: BOOLEAN);
  1826.                 { Resizes SELF to 'width' & 'height', and forces an invalidation if 'invalidate' is
  1827.                 TRUE. }
  1828.  
  1829.                 PROCEDURE TView.SuperViewChangedSize(delta: VPoint;
  1830.                                                      invalidate: BOOLEAN);
  1831.                 { Called when our superview changes size. }
  1832.  
  1833.                 PROCEDURE TView.SubViewChangedSize(theSubView: TView;
  1834.                                                    delta: VPoint);
  1835.                 { Called when one of our subviews changes size. }
  1836.  
  1837.                 { Location Methods }
  1838.  
  1839.                 PROCEDURE TView.Locate(h, v: VCoordinate;
  1840.                                        invalidate: BOOLEAN);
  1841.                 { Moves our view to coordinate 'h' & 'v' invalidating if 'invalidate' is TRUE. }
  1842.  
  1843.                 PROCEDURE TView.SubViewMoved(theSubView: TView);
  1844.                 { Called when a subview is moved. }
  1845.  
  1846.                 PROCEDURE TView.SuperViewMoved(invalidate: BOOLEAN);
  1847.                 { Called when our superview is moved. }
  1848.  
  1849.                 { Focusing Methods }
  1850.  
  1851.                 FUNCTION TView.Focus: BOOLEAN;
  1852.                 { Attempts to set up the drawing environment for this view. That consists of port,
  1853.                 origin, gLongOffset and clipping. Returns FALSE if not able to focus. One reason
  1854.                 focus could fail is if no superview is able to supply a port (ie not in a window
  1855.                 and not printing or drawing pict scrap). Focus will return true, however, if the
  1856.                 drawing environment can be setup but none of the view is currently visible due to
  1857.                 clipping or scrolling by a superview. This lets you assemble view hierarchies and
  1858.                 manipulate views without showing them to the user, but requires that you test
  1859.                 IsVisible if you MUST know if the view is in fact visible. (MacApp will never ask a
  1860.                 view to draw unless it is visible) }
  1861.  
  1862.                 FUNCTION TView.FocusOnSuperView: BOOLEAN;
  1863.                 { Focuses on our superview. }
  1864.  
  1865.                 PROCEDURE TView.InvalidateFocus;
  1866.                 { Indicates that the view's focus is no longer valid and must be recomputed. }
  1867.  
  1868.                 FUNCTION TView.IsFocused: BOOLEAN;
  1869.                 { Check to see if we are currently focused. }
  1870.  
  1871.                 PROCEDURE TView.ClipFurtherTo(r: Rect;
  1872.                                               hDeltaOrg, vDeltaOrg: INTEGER);
  1873.                 { Set clipping to: (<current clipping> INTERSECT r) OFFSET-BY (hDeltaOrg, vDeltaOrg).
  1874.                 }
  1875.  
  1876.                 PROCEDURE TView.AssumeFocused;
  1877.                 { Causes a ProgramBreak if the focused view isn't SELF }
  1878.  
  1879.                 { Drawing Methods }
  1880.  
  1881.                 {$IFC qExperimentalAndUnsupported}
  1882.                 PROCEDURE TView.DoOffScreen(PROCEDURE WhatToDo);
  1883.                 { The WhatToDo procedure is performed while focused "offscreen" and the results
  1884.                 are blitted back on to the screen. }
  1885.                 {$EndC}
  1886.  
  1887.                 PROCEDURE TView.DrawContents;
  1888.                 { Causes the views contents to be drawn and that of any of its subviews. }
  1889.  
  1890.                 PROCEDURE TView.Draw(area: Rect);
  1891.                 { Currently does nothing. Must be overridden. }
  1892.  
  1893.                 PROCEDURE TView.DoHighlightSelection(fromHL, toHL: HLState);
  1894.                 { Currently does nothing. Must be overridden. }
  1895.  
  1896.                 PROCEDURE TView.Adorn(area: Rect;
  1897.                                       itsPenSize: Point;
  1898.                                       itsAdornment: CntlAdornment);
  1899.                 { Handles the adornment of the view based on the CntlAdornment enumeration. }
  1900.  
  1901.                 FUNCTION TView.HasPendingUpdate: BOOLEAN;
  1902.                 { Returns TRUE if there is a pending update event for this view, FALSE if not. }
  1903.  
  1904.                 PROCEDURE TView.Update;
  1905.                 { If its window is not NIL then does an update by calling DrawContents. }
  1906.  
  1907.                 { Validation/Invalidation Methods }
  1908.  
  1909.                 PROCEDURE TView.ForceRedraw;
  1910.                 { Invalidates the entire view forcing a redraw. }
  1911.  
  1912.                 PROCEDURE TView.InvalidVRect(viewRect: VRect);
  1913.                 { Invalidates a view rect. }
  1914.  
  1915.                 PROCEDURE TView.ValidVRect(viewRect: VRect);
  1916.             { Converts 'viewRect' to a QD Rect then calls VisibleRect & ValidRect with the result. }
  1917.  
  1918.                 PROCEDURE TView.InvalidRect(r: Rect);
  1919.                 { Invalidates a Quickdraw rect. }
  1920.  
  1921.                 PROCEDURE TView.RevealRect(rectToReveal: VRect;
  1922.                                            minToSee: Point;
  1923.                                            redraw: BOOLEAN);
  1924.                 { Scrolls a rect in to view, with 'minToSee' being the point which will end up at the
  1925.                 bottom of the view, i.e.the minimum amount to be seen and 'rectToReveal' the rect
  1926.                 being scrolled. }
  1927.  
  1928.                 PROCEDURE TView.RevealTop(redraw: BOOLEAN);
  1929.                 { Scroll the top of a rect into view. }
  1930.  
  1931.                 PROCEDURE TView.RevealBottom(redraw: BOOLEAN);
  1932.                 { Scroll the bottom of a rect into view. }
  1933.  
  1934.                 { Mouse Handling Methods }
  1935.  
  1936.                 FUNCTION TView.ContainsMouse(theMouse: VPoint): BOOLEAN;
  1937.                 { Is the view point 'theMouse' currently in our view. }
  1938.  
  1939.                 FUNCTION TView.HandleMouseDown(theMouse: VPoint;
  1940.                                                VAR info: EventInfo;
  1941.                                                VAR hysteresis: Point;
  1942.                                                VAR theCommand: TCommand): BOOLEAN;
  1943.                 { The method responsible for handling a mouse down in the view, calls DoMouseCommand
  1944.                 to handle it. }
  1945.  
  1946.                 FUNCTION TView.DoMouseCommand(VAR theMouse: Point;
  1947.                                               VAR info: EventInfo;
  1948.                                               VAR hysteresis: Point): TCommand;
  1949.                 { Returns a simple tracker which by default calls back tracking methods of this view.
  1950.                 There are two possibilities here:
  1951.                 1)    Override DoMouseCommand to return commands that represent more complex, even
  1952.                 undoable actions.  That command may either let its tracking call back the view's
  1953.                 tracking methods (the default) which must be overridden to do anything useful or it
  1954.                 may simply do all the tracking itself.    This mostly depends on whether different
  1955.                 commands returned from the view would have different tracking behavior.  For example
  1956.                 this is the approach taken by DrawShapes.
  1957.                 2) Override the view's tracking methods and let the default tracker them.  For example
  1958.                 this is the approach taken by TControl. }
  1959.  
  1960.                 { Cursor Handling Methods }
  1961.  
  1962.                 FUNCTION TView.HandleCursor(theMouse: VPoint;
  1963.                                             cursorRgn: RgnHandle): TView;
  1964.                 { Handles the setting of the cursor by calling our DoSetCursor method and the same
  1965.                 For all our subviews. }
  1966.  
  1967.                 FUNCTION TView.DoSetCursor(localPoint: Point;
  1968.                   { By default merely returns FALSE. }
  1969.                                            cursorRgn: RgnHandle): BOOLEAN;
  1970.  
  1971.                 PROCEDURE TView.GetDefaultCursorRgn(localPoint: Point;
  1972.                                                        cursorRgn: RgnHandle);
  1973.                 { Returns the largest appropriate cursor region, called by DoSetCursor. }
  1974.                 
  1975.                 { Miscellaneous Methods }
  1976.  
  1977.                 FUNCTION TView.GetDialogView: TView;    { actually, TDialogView… }
  1978.                 { If our superview is not NIL then calls its GetDialogView method and returns the
  1979.                 result, otherwise returns NIL. }
  1980.  
  1981.                 FUNCTION TView.GetGrafPort: GrafPtr;
  1982.                 { Returns a pointer to our Graf Port. }
  1983.  
  1984.                 FUNCTION TView.GetScroller(immediateSuperView: BOOLEAN): TScroller;
  1985.                 { Returns a reference to our scroller. }
  1986.  
  1987.                 FUNCTION TView.GetWindow: TWindow;
  1988.                 { Returns a reference to the window that we are in, if any. }
  1989.  
  1990.                 PROCEDURE TView.GetExtent(VAR itsExtent: VRect);
  1991.                 { Returns a view rect the size of our extent in 'itsExtent'. }
  1992.  
  1993.                 PROCEDURE TView.GetQDExtent(VAR qdExtent: Rect);
  1994.                 { Returns a Quickdraw rect the size of our extent in 'qdExtent'. }
  1995.  
  1996.                 PROCEDURE TView.GetFrame(VAR itsFrame: VRect);
  1997.                 { Returns in'itsFrame' a VRect that is the boundary of our view in superview
  1998.                 coordinates. This is calculated by adding its size to its location. }
  1999.  
  2000.                 PROCEDURE TView.GetVisibleRect(VAR visQDRect: Rect);
  2001.                 { Retuns a Quickdraw rect the size of the visible amount of our view. }
  2002.  
  2003.                 PROCEDURE TView.ViewEnable(state, redraw: BOOLEAN);
  2004.                 { Enables & Redraws the view based on 'state' & 'redraw'. }
  2005.  
  2006.                 FUNCTION TView.IsViewEnabled: BOOLEAN;
  2007.                 { Checks to see if our view is currently enabled. }
  2008.  
  2009.                 PROCEDURE TView.Show(state, redraw: BOOLEAN);
  2010.                 { If 'state' is not fShown then set fShown to TRUE and call ForceRedraw if 'redraw'
  2011.                 is TRUE. Otherwise invalidate our focus and set fShown to 'state'. }
  2012.  
  2013.                 FUNCTION TView.IsShown: BOOLEAN;
  2014.                 { Checks to see if our view is currently shown. }
  2015.  
  2016.                 FUNCTION TView.IsVisible: BOOLEAN;
  2017.                 { Returns TRUE if any portion of the view is currently visible when focused }
  2018.  
  2019.                 { Clipboard Handling }
  2020.  
  2021.                 FUNCTION TView.ContainsClipType(aType: ResType): BOOLEAN;
  2022.                 { Checks to see if the clipboard contains the type 'aType'. }
  2023.  
  2024.                 FUNCTION TView.GivePasteData(aDataHandle: Handle;
  2025.                                              dataType: ResType): LONGINT;
  2026.               { Gets the scrap data of the type 'dataType', returns any errors as function result. }
  2027.  
  2028.                 PROCEDURE TView.WriteToDeskScrap;
  2029.                 { Writes to desk scrap. }
  2030.  
  2031.                 { PrintingMethods }
  2032.  
  2033.                 PROCEDURE TView.AttachPrintHandler(itsPrintHandler: TPrintHandler);
  2034.                 { Called by the PrintHandler during its initialization, NOT directly by you }
  2035.  
  2036.                 FUNCTION TView.DoBreakFollowing(vhs: VHSelect;
  2037.                                                 prevBreak: VCoordinate;
  2038.                                                 VAR automatic: BOOLEAN): VCoordinate;
  2039.                 { Returns the location of the page break which follows the page break located at
  2040.                 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
  2041.                 thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
  2042.                 page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
  2043.                 horizontal lines }
  2044.  
  2045.                 PROCEDURE TView.DoCalcPageStrips(VAR pageStrips: Point);
  2046.                 { Computes the number of horizontal and vertical page strips. }
  2047.  
  2048.                 PROCEDURE TView.DoCalcViewPerPage(VAR viewPerPage: VPoint);
  2049.                 { Determine how much of the view normally goes into each printed page, in each
  2050.                 dimension. }
  2051.  
  2052.                 PROCEDURE TView.DoCheckPrinter;
  2053.                 { Check whether printer (if relevant) has changed, and if so, take appropriate action
  2054.                 }
  2055.  
  2056.                 PROCEDURE TView.DoDrawPrintFeedback(area: Rect);
  2057.                 { Draw page-breaks, page-numbers, view-borders, rulers, etc. }
  2058.  
  2059.                 PROCEDURE TView.DoDrawPageBreak(vhs: VHSelect;
  2060.                                                 whichBreak: INTEGER;
  2061.                                                 loc: VCoordinate;
  2062.                                                 automatic: BOOLEAN);
  2063.                 { Draw one page break. }
  2064.  
  2065.                 FUNCTION TView.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  2066.                 { Enables my fPrintHandler to handle commands }
  2067.  
  2068.                 PROCEDURE TView.DoPagination;
  2069.                 { Recompute the dividing lines between areas of the view which will be mapped into
  2070.                 different printed pages }
  2071.  
  2072.                 PROCEDURE TView.DoPrinterChanged;
  2073.                 { The metrics relating to printer use have changed; absorb the information and react
  2074.                 }
  2075.  
  2076.                 PROCEDURE TView.DoSetPageOffset(coord: VPoint);
  2077.                 { Only reimplement in very unusual circumstances involving Tall-UnAdjusted text
  2078.                 printing etc. }
  2079.  
  2080.                 PROCEDURE TView.DoSetupMenus; OVERRIDE;
  2081.                 { Tells my PrintHandler to set up its menus }
  2082.  
  2083.                 PROCEDURE TView.GetPrintExtent(VAR printExtent: VRect);
  2084.                 { Returns the part of the view that is to be printed. The default is to return the
  2085.                 view's extent. }
  2086.  
  2087.                 PROCEDURE TView.PageInteriorChanged(newInterior: Rect);
  2088.                 { Allows a view which is printable to react to the changing of the page-interior
  2089.                 rectangle }
  2090.  
  2091.                 { Inspecting Methods }
  2092.  
  2093.                 PROCEDURE TView.Fields(PROCEDURE DoToField(fieldName: Str255;
  2094.                                                            fieldAddr: Ptr;
  2095.                                                            fieldType: INTEGER)); OVERRIDE;
  2096.                 { Called by the Inspector and the Debugger to display the contents of this class's
  2097.                 fields. }
  2098.  
  2099.                 PROCEDURE TView.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  2100.                 { Called by the Inspector to get the name of this class. }
  2101.  
  2102.                 { Tracking Methods }
  2103.  
  2104.                 FUNCTION TView.IsDoneTracking: BOOLEAN;
  2105.                 { Indicates whether the Tracker is through tracking.  (the command is also through
  2106.                 tracking if you return NIL from TrackMouse).  Defaults to NOT StillDown.
  2107.                 Most programs won't have to mess with this.
  2108.                 NOTE you still have to deal with queued events if you change the criteria for TRUE. }
  2109.  
  2110.                 PROCEDURE TView.TrackConstrain(anchorPoint, previousPoint: VPoint;
  2111.                                                VAR nextPoint: VPoint);
  2112.                 { Override this if your Tracker calls back to the view (the Default) an you want to
  2113.                 constrain the mouse point to a grid, force drawing a square, etc. This is called only
  2114.                 if fConstrainsMouse is TRUE. }
  2115.  
  2116.                 PROCEDURE TView.TrackFeedback(anchorPoint, nextPoint: VPoint;
  2117.                                               turnItOn, mouseDidMove: BOOLEAN);
  2118.                 { Override this if your Tracker calls back to the view (the Default) an you want to
  2119.                 display any tracking feedback }
  2120.  
  2121.                 PROCEDURE TView.TrackMouse(aTrackPhase: TrackPhase;
  2122.                                            VAR anchorPoint, previousPoint, nextPoint: VPoint;
  2123.                                            mouseDidMove: BOOLEAN);
  2124.                 { Override this if your Tracker calls back to the view (the Default) an you want to
  2125.                 display any tracking feedback }
  2126.  
  2127.                 END;
  2128.  
  2129. {--------------------------------------------------------------------------------------------------}
  2130.             { Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the focus
  2131.             behind MacApp's back. One use is to speed up scrolling (see TScroller). }
  2132.             {$IFC NOT qExperimentalAndUnsupported}
  2133.             FocusRec            = RECORD
  2134.                 printing:            BOOLEAN;
  2135.                 drawingPictScrap:    BOOLEAN;
  2136.                 drawingPictScrapView: TView;
  2137.                 focusedView:        TView;
  2138.                 longOffset:         VPoint;
  2139.                 org:                Point;
  2140.                 port:                GrafPtr;
  2141.                 clip:                RgnHandle;
  2142.                 isValid:            BOOLEAN;        { TRUE if FocusRec is valid }
  2143.                 END;
  2144.             {$EndC}
  2145. {--------------------------------------------------------------------------------------------------}
  2146.             ScrollerTemplate    = RECORD
  2147.                 wantVSBar:            BOOLEAN;
  2148.                 wantHSBar:            BOOLEAN;
  2149.                 vertMax:            LONGINT;
  2150.                 horzMax:            LONGINT;
  2151.                 vScrollUnits:        INTEGER;
  2152.                 hScrollUnits:        INTEGER;
  2153.                 vConstrain:         BOOLEAN;
  2154.                 hConstrain:         BOOLEAN;
  2155.                 sBarOffsets:        Rect;
  2156.                 END;
  2157.             ScrollerTemplatePtr = ^ScrollerTemplate;
  2158.  
  2159.             TScroller            = OBJECT (TView)        { A view which can "scroll" its contents by
  2160.                                                          translating coordinates. }
  2161.  
  2162.                 fTranslation:        VPoint;             { the current amount of translation }
  2163.                 fScrollLimit:        VPoint;             { the 'limit' of the subview that should be
  2164.                                                          scrollable }
  2165.                 fMaxTranslation:    VPoint;             { the derived maximum amount of translation
  2166.                                                          taking into account the visible portion of
  2167.                                                          the view. This keeps us from scrolling the
  2168.                                                          bottom of a view to the top of a window }
  2169.                 fScrollBars:        ARRAY [VHSelect] OF TSScrollBar; { associated scroll bars if any
  2170.                                                                       }
  2171.                 fScrollUnit:        Point;                { increment of scroll }
  2172.                 fConstrain:         ARRAY [VHSelect] OF BOOLEAN; { should scrolling be constrained
  2173.                                                                   to a multiple of my scrollunit }
  2174.                 fSBarOffsets:        VRect;                { how much to offset the associated scroll
  2175.                                                          bars from my bounds }
  2176.                 fRespondsToFunctionKeys: BOOLEAN;        { if it responds to PgUp/PgDn, etc. }
  2177.  
  2178.                                      { Creation/Destruction Methods }
  2179.  
  2180.                 PROCEDURE TScroller.IScroller(itsSuperView: TView;
  2181.                                               itsLocation, itsSize: VPoint;
  2182.                                               itsHSizeDet, itsVSizeDet: SizeDeterminer;
  2183.                                               itsHorzMax, itsVertMax: VCoordinate;
  2184.                                               wantHorzSBar, wantVertSBar: BOOLEAN);
  2185.                 { Called to initialize a scroller procedurally. }
  2186.  
  2187.                 PROCEDURE TScroller.CreateScrollBar(itsDirection: VHSelect);
  2188.                 { Called to create a scrollbar in 'itsDirection'. }
  2189.  
  2190.                 PROCEDURE TScroller.IRes(itsDocument: TDocument;
  2191.                                          itsSuperView: TView;
  2192.                                          VAR itsParams: Ptr); OVERRIDE;
  2193.                 { Initialize a scroller from a resource template. }
  2194.  
  2195.                 PROCEDURE TScroller.CreateTemplateScrollBar(itsDirection: VHSelect);
  2196.                 { Called to create a scrollbar in 'itsDirection' from a resource template. }
  2197.  
  2198.                 PROCEDURE TScroller.WRes(theResource: ViewRsrcHndl;
  2199.                                          VAR itsParams: Ptr); OVERRIDE;
  2200.                 { For writing a scroller view out to a resource. }
  2201.  
  2202.                 PROCEDURE TScroller.WriteRes(theResource: ViewRsrcHndl;
  2203.                                              VAR itsParams: Ptr); OVERRIDE;
  2204.                 { For writing a scroller to a resource, works in conjunction with tbe previous
  2205.                 method. }
  2206.  
  2207.                 PROCEDURE TScroller.Free; OVERRIDE;
  2208.                 { If there are attached scrollbars frees them before calling inherited Free. }
  2209.  
  2210.                 { SubView Management Methods }
  2211.  
  2212.                 PROCEDURE TScroller.AddSubView(theSubView: TView); OVERRIDE;
  2213.                 { Calls inherited AddSubView and then calls 'theSubView' to BeInScroller passing SELF
  2214.                 as the scroller to be in. }
  2215.  
  2216.                 PROCEDURE TScroller.RemoveSubView(theSubView: TView); OVERRIDE;
  2217.                 { Calls BeInScroller with a parameter of NIL, for 'theSubView', before calling
  2218.                 inherited RemoveSubView. }
  2219.  
  2220.                 { Focusing Methods }
  2221.  
  2222.                 FUNCTION TScroller.Focus: BOOLEAN; OVERRIDE;
  2223.                 { Attempts to Focus the scroller by calling inherited Focus and setting the
  2224.                 gLongOffset }
  2225.  
  2226.                 PROCEDURE TScroller.ForceRedraw; OVERRIDE;
  2227.                 { Invalidates the entire view forcing a redraw. }
  2228.  
  2229.                 { Miscellaneous Methods }
  2230.  
  2231.                 PROCEDURE TScroller.LocalToSuper(VAR thePoint: VPoint); OVERRIDE;
  2232.                 { Given a point in local coordinates, returns the same point in its superview's
  2233.                 coordinate system. }
  2234.  
  2235.                 PROCEDURE TScroller.SuperToLocal(VAR thePoint: VPoint); OVERRIDE;
  2236.                 { Given a point in superview coordinates, returns the same point in the view's own
  2237.                 coordinate system. }
  2238.  
  2239.                 PROCEDURE TScroller.GetExtent(VAR itsExtent: VRect); OVERRIDE;
  2240.                 { Returns the extent of the scroller. }
  2241.  
  2242.                 { Size Methods }
  2243.  
  2244.                 PROCEDURE TScroller.Resize(width, height: VCoordinate;
  2245.                                            invalidate: BOOLEAN); OVERRIDE;
  2246.                 { Resizes the scroller to 'width' & 'height', redrawing if 'invalidate' is TRUE. }
  2247.  
  2248.                 { Location Methods }
  2249.  
  2250.                 PROCEDURE TScroller.Locate(h, v: VCoordinate;
  2251.                                            invalidate: BOOLEAN); OVERRIDE;
  2252.                 { Calls inherited Locate before calling AdjustScrollbars. }
  2253.  
  2254.                 PROCEDURE TScroller.AdjustScrollBars(invalidate: BOOLEAN);
  2255.                 { Resizes and re-Locates the scrollbars if required. }
  2256.  
  2257.                 PROCEDURE TScroller.SubViewChangedSize(theSubView: TView;
  2258.                                                        delta: VPoint); OVERRIDE;
  2259.                 { Adjust the scroll limits based on the size change of the subviews. }
  2260.  
  2261.                 PROCEDURE TScroller.SetScrollLimits(scrollLimit: VPoint;
  2262.                                                     drawScrollBars: BOOLEAN);
  2263.                 { Sets the scroll of the attached scrollbars, if there are any. }
  2264.  
  2265.                 PROCEDURE TScroller.SetScrollParameters(horzUnits, vertUnits: VCoordinate;
  2266.                                                         horzConstraint, vertConstraint: BOOLEAN);
  2267.                 { Sets up the fScrollUnit and fConstrain fields of the scroller. }
  2268.  
  2269.                 { Scrolling Methods }
  2270.  
  2271.                 PROCEDURE TScroller.HaveScrollBar(theScrollBar: TSScrollBar;
  2272.                                                   direction: VHSelect);
  2273.                 { Sets the fScrollbar field in the given 'direction' to 'theScrollBar'. }
  2274.  
  2275.                 PROCEDURE TScroller.ScrollDraw(delta: VPoint;
  2276.                                            invalidate: BOOLEAN);
  2277.                 { Method responsible for actually doing the scrolling by calling moving bits. Called
  2278.                 by DoScroll.  Invalidates newly revealed area if invalidate is true else updates
  2279.                 the redraws the newly revealed area if invalidate is false.
  2280.                 !!! NOTE this does not match the behaviour of other invalidate parameters because they
  2281.                 interpret invalidate equals FALSE to neither draw nor invalidate.   Well we already
  2282.                 know that the way that invalidate/redraw/don't-render control is handled needs _MAJOR_
  2283.                 overhauling anyways… Sigh! }
  2284.  
  2285.                 PROCEDURE TScroller.DoScroll(delta: VPoint;
  2286.                                              redraw: BOOLEAN);
  2287.                 { Method responsible for handling the scrolling, calls ScrollDraw if required. }
  2288.  
  2289.                 FUNCTION TScroller.ScrollStep(vhs: VHSelect;
  2290.                                               partCode: INTEGER): VCoordinate;
  2291.                 { Depending on the 'partCode' returns the amount to be scrolled. }
  2292.  
  2293.                 FUNCTION TScroller.ScrollRelative(vhs: VHSelect;
  2294.                                                   sBarValue: VCoordinate): VCoordinate;
  2295.                 { Returns the relative amount to scroll. }
  2296.  
  2297.                 PROCEDURE TScroller.ScrollBy(deltaH, deltaV: VCoordinate;
  2298.                                              redraw: BOOLEAN);
  2299.                 { Called to scroll by 'deltaH & 'deltaV'. }
  2300.  
  2301.                 PROCEDURE TScroller.ScrollTo(h, v: VCoordinate;
  2302.                                              redraw: BOOLEAN);
  2303.                 { Scroll to the required coordinates, calls ScrollBy. }
  2304.  
  2305.                 PROCEDURE TScroller.AutoScroll(viewPt: VPoint;
  2306.                                                VAR delta: VPoint);
  2307.                 { Called during auto scrolling to return the delta to be scrolled. }
  2308.  
  2309.                 PROCEDURE TScroller.RevealRect(rectToReveal: VRect;
  2310.                                                minToSee: Point;
  2311.                                                redraw: BOOLEAN); OVERRIDE;
  2312.                 { Shows 'rectToReveal' with the minimum amount to be seen set to 'minToSee' by
  2313.                 calling ScrollBy. }
  2314.  
  2315.                 { Miscellaneous Methods }
  2316.  
  2317.                 FUNCTION TScroller.DoKeyCommand(ch: Char;
  2318.                                                 aKeyCode: INTEGER;
  2319.                                                 VAR info: EventInfo): TCommand; OVERRIDE;
  2320.                 { Handles when the Home, End, PageUp & PageDown keys are used. }
  2321.  
  2322.                 FUNCTION TScroller.GetScroller(immediateSuperView: BOOLEAN): TScroller; OVERRIDE;
  2323.                 { Returns SELF. }
  2324.  
  2325.                 { Inspecting Methods }
  2326.  
  2327.                 PROCEDURE TScroller.Fields(PROCEDURE
  2328.                                            DoToField(fieldName: Str255;
  2329.                                                      fieldAddr: Ptr;
  2330.                                                      fieldType: INTEGER)); OVERRIDE;
  2331.                 { Used by the Inspector and the Debugger to display the contents of this class's
  2332.                 fields. }
  2333.  
  2334.                 END;
  2335.  
  2336. {--------------------------------------------------------------------------------------------------}
  2337.             WindowTemplate        = PACKED RECORD
  2338.                 procID:             INTEGER;
  2339.                 hasGoAway:            BOOLEAN;
  2340.                 resizable:            BOOLEAN;
  2341.                 isModal:            BOOLEAN;
  2342.                 doFirstClick:        BOOLEAN;
  2343.                 freeOnClosing:        BOOLEAN;
  2344.                 disposeOnFree:        BOOLEAN;
  2345.                 closesDocument:     BOOLEAN;
  2346.                 openInitially:        BOOLEAN;
  2347.                 mustAdaptToScreen:    BOOLEAN;
  2348.                 stagger:            BOOLEAN;
  2349.                 mustForceOnScreen:    BOOLEAN;
  2350.                 vertCenter:         BOOLEAN;
  2351.                 horzCenter:         BOOLEAN;
  2352.                 filler:             0..7;
  2353.                 targetID:            IDType;
  2354.                 title:                Str255;             {Actually variable length}
  2355.                 END;
  2356.             WindowTemplatePtr    = ^WindowTemplate;
  2357.  
  2358.             TWindow             = OBJECT (TView)        { Corresponds to a desktop Window. The
  2359.                                                          outermost of a nested set of views. }
  2360.                 fWMgrWindow:        WindowPtr;            { the window manager window Ptr }
  2361.                 fProcID:            INTEGER;            { the proc ID of the window }
  2362.                 fMoveBounds:        Rect;                { bounds over which the window may be moved
  2363.                                                          }
  2364.                 fResizeLimits:        Rect;                { limits over which the window may be
  2365.                                                          resized }
  2366.                 fTarget:            TEvtHandler;        { when this window is activated; the
  2367.                                                          TEvtHandler to SetTarget on }
  2368.                 fTargetID:            IDType;             { corresponding ID to fTarget }
  2369.                 fPreDocname:        INTEGER;            { amount of window title that precedes the
  2370.                                                          document name }
  2371.                 fConstTitle:        INTEGER;            { amount of the title name that is constant
  2372.                                                          }
  2373.                 fIsActive:            BOOLEAN;            { is this window active }
  2374.                 fIsResizable:        BOOLEAN;            { is this window resizeable }
  2375.                 fIsClosable:        BOOLEAN;            { is this window closable }
  2376.                 fFreeOnClosing:     BOOLEAN;            { should this window free itself when it
  2377.                                                          closes }
  2378.                 fDisposeOnFree:     BOOLEAN;            { should the window manager window be
  2379.                                                          disposed when this window frees }
  2380.                 fClosesDocument:    BOOLEAN;            { does this window close the document }
  2381.                 fOpenInitially:     BOOLEAN;            { should this window be opened when its
  2382.                                                          document is asked to show its windows }
  2383.                 fIsModal:            BOOLEAN;            { should this window behave modally }
  2384.                 fDoFirstClick:        BOOLEAN;            { should a click in this window not only
  2385.                                                          select it if it is inactive but also be
  2386.                                                          sent to its contents }
  2387.                 fMustAdapt:         BOOLEAN;            { does this window require adaption to the
  2388.                                                          screen }
  2389.                 fMustHorzCenter:    BOOLEAN;            { does this window require centering
  2390.                                                          horizontally }
  2391.                 fMustVertCenter:    BOOLEAN;            { does this window require centering
  2392.                                                          vertically }
  2393.                 fMustStagger:        BOOLEAN;            { does this window require staggering }
  2394.                 fMustForceOnScreen: BOOLEAN;            { does this window require forcing on the
  2395.                                                          screen }
  2396.                 fAdapted:            BOOLEAN;            { has this window's size ever been adapted
  2397.                                                          to the screen }
  2398.                 fHorzCentered:        BOOLEAN;            { has this window been centered horizontally
  2399.                                                          }
  2400.                 fVertCentered:        BOOLEAN;            { has this window been centered vertically }
  2401.                 fStaggered:         BOOLEAN;            { has this window been staggered }
  2402.                 fForcedOnScreen:    BOOLEAN;            { has this window been forced on the screen
  2403.                                                          }
  2404.                 fFloats:            BOOLEAN;            { does this window float above non-floating
  2405.                                                          windows (NOT SUPPORTED IN 2.0) }
  2406.                 fContRgnInset:        Point;                { topleft inset of cont rgn in struc rgn }
  2407.                 fContDifference:    Point;                { total amount the content is less than and
  2408.                                                          offset into the structure (Accounts for
  2409.                                                          title bar, etc.) }
  2410.  
  2411.                                 { Creation/Destruction Methods }
  2412.  
  2413.                 PROCEDURE TWindow.IWindow(itsDocument: TDocument;
  2414.                                           itsWMgrWindow: WindowPtr;
  2415.                                           canResize, canClose, disposeOnFree: BOOLEAN);
  2416.                 { Initialize a window procedurally. }
  2417.  
  2418.                 PROCEDURE TWindow.IRes(itsDocument: TDocument;
  2419.                                        itsSuperView: TView;
  2420.                                        VAR itsParams: Ptr); OVERRIDE;
  2421.                 { Initialize a window from a resource template. }
  2422.  
  2423.                 PROCEDURE TWindow.WRes(theResource: ViewRsrcHndl;
  2424.                                        VAR itsParams: Ptr); OVERRIDE;
  2425.                 { For writing a window out to a resource. }
  2426.  
  2427.                 PROCEDURE TWindow.WriteRes(theResource: ViewRsrcHndl;
  2428.                                            VAR itsParams: Ptr); OVERRIDE;
  2429.                 { For writing a TWindow to a resource, works in conjunction with tbe previous
  2430.                 method. }
  2431.  
  2432.                 PROCEDURE TWindow.Free; OVERRIDE;
  2433.                 { Frees the window if fDisposeOnFree is TRUE, also deletes the window from the
  2434.                 document if there is one, otherwise deletes it from the applications list of free
  2435.                 windows. }
  2436.  
  2437.                 { Open/Close Methods }
  2438.  
  2439.                 PROCEDURE TWindow.Open; OVERRIDE;
  2440.                 { Makes the window visible by showing it before calling inherited Open. }
  2441.  
  2442.                 PROCEDURE TWindow.Close; OVERRIDE;
  2443.                 { Calls inherited Close and the hides & deactivates the window. }
  2444.  
  2445.                 PROCEDURE TWindow.CloseByUser;
  2446.                 { If the window is shown and it can be closed handles the closing. }
  2447.  
  2448.                 PROCEDURE TWindow.GoAwayByUser(globalMouse: Point);
  2449.                 { Responsible for calling CloseByUser. }
  2450.  
  2451.                 { Activation Methods }
  2452.  
  2453.                 PROCEDURE TWindow.Activate(entering: BOOLEAN); OVERRIDE;
  2454.                 { Activate the window. }
  2455.  
  2456.                 { Size/Location Methods }
  2457.  
  2458.                 PROCEDURE TWindow.Locate(h, v: VCoordinate;
  2459.                                          invalidate: BOOLEAN); OVERRIDE;
  2460.                 { If fWMgrWindow is not NIL then MoveWindow to relocate the window. }
  2461.  
  2462.                 PROCEDURE TWindow.MoveByUser(globalMouse: Point);
  2463.                 { Handles the user moving the window by dragging the title bar, calls DragWindow to
  2464.                 handle movement. }
  2465.  
  2466.                 PROCEDURE TWindow.ResizeByUser(globalMouse: Point);
  2467.                 { Handles the user resizing the window by dragging the growbox, calls GrowWindow to
  2468.                 handle movement and Resize to resize the window. }
  2469.  
  2470.                 PROCEDURE TWindow.Resize(width, height: VCoordinate;
  2471.                                          invalidate: BOOLEAN); OVERRIDE;
  2472.                 { Used to resize the window by setting its width & height to the parameters passed
  2473.                 in. }
  2474.  
  2475.                 PROCEDURE TWindow.Zoom(partCode: INTEGER);
  2476.                 { Responsible for actually handling the zooming of a window when the user clicks in
  2477.                 the zoombox. }
  2478.  
  2479.                 PROCEDURE TWindow.ZoomByUser(globalMouse: Point;
  2480.                                              partCode: INTEGER);
  2481.                 { handles the user clicking in the zoombox to zoom the window, calls Zoom. }
  2482.  
  2483.                 { Focusing Methods }
  2484.  
  2485.                 FUNCTION TWindow.Focus: BOOLEAN; OVERRIDE;
  2486.                 { Attempts to set the Focus to the window, returns TRUE if it succeeds, FALSE if not.
  2487.                 }
  2488.  
  2489.                 FUNCTION TWindow.FocusOnSuperView: BOOLEAN; OVERRIDE;
  2490.                 { Attempts to set the Focus to our superview, returning TRUE if it succeeds or FALSE
  2491.                 if not. }
  2492.  
  2493.                 { Drawing Methods }
  2494.  
  2495.                 PROCEDURE TWindow.DrawContents; OVERRIDE;
  2496.                { Does an EraseRect and calls inherited DrawContents before calling DrawResizeIcon. }
  2497.  
  2498.                 PROCEDURE TWindow.DrawResizeIcon;
  2499.                 { Draws the grow icon by calling the toolbox routine DrawGrowIcon. }
  2500.  
  2501.                 { Mouse Handling Methods }
  2502.  
  2503.                 FUNCTION TWindow.HandleMouseDown(theMouse: VPoint;
  2504.                                                  VAR info: EventInfo;
  2505.                                                  VAR hysteresis: Point;
  2506.                                                  VAR theCommand: TCommand): BOOLEAN; OVERRIDE;
  2507.                 { Handles mouse downs in the window. }
  2508.  
  2509.                 FUNCTION TWindow.HasPendingUpdate: BOOLEAN; OVERRIDE;
  2510.                 { Returns TRUE if there is a pending update event for this window, FALSE if not. }
  2511.  
  2512.                 PROCEDURE TWindow.Update; OVERRIDE;
  2513.                 { Handle the update region and drawcontents on SELF. }
  2514.  
  2515.                 { Menu Handling Methods}
  2516.  
  2517.                 FUNCTION TWindow.AllowsMenuAccess: BOOLEAN;
  2518.                 { By default returns TRUE. }
  2519.  
  2520.                 PROCEDURE TWindow.DoSetupMenus; OVERRIDE;
  2521.                 { If the window is not modal calls inherited DoSetupMenus. }
  2522.  
  2523.                 FUNCTION TWindow.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  2524.                 { Handles closing the window. }
  2525.  
  2526.                 { Misc. Methods }
  2527.  
  2528.                 PROCEDURE TWindow.Show(state, redraw: BOOLEAN); OVERRIDE;
  2529.                 { Called to make the window visible or not based on 'state'. }
  2530.  
  2531.                 FUNCTION TWindow.IsShown: BOOLEAN; OVERRIDE;
  2532.                 { Returns TRUE if the window is currently shown. }
  2533.  
  2534.                 PROCEDURE TWindow.Select;
  2535.                 { Called to select the window. }
  2536.  
  2537.                 PROCEDURE TWindow.SetTitle(newTitle: Str255);
  2538.                 { Sets the windows title to 'newTitle'. }
  2539.  
  2540.                 PROCEDURE TWindow.GetTitle(VAR theTitle: Str255);
  2541.                 { Gets the current title of the window. }
  2542.  
  2543.                 PROCEDURE TWindow.SetTitleForDoc(newDocTitle: Str255);
  2544.                 { Called when the documents name is known or changed }
  2545.  
  2546.                 PROCEDURE TWindow.AdaptToScreen;
  2547.                 { Resizes the window to fit the screen on which it is being displayed. }
  2548.  
  2549.                 PROCEDURE TWindow.ForceOnScreen;
  2550.                 { ForceOnScreen gaurantees that some minimal drag area is accessible to the user,
  2551.                   to be dragged to the desired location. }
  2552.  
  2553.                 PROCEDURE TWindow.Center(horizontally, vertically, forDialog: BOOLEAN);
  2554.                 { Centers the window on the screen either horizontally, vertically or both. }
  2555.  
  2556.                 PROCEDURE TWindow.SimpleStagger(dh, dv: INTEGER;
  2557.                                                 VAR counter: INTEGER);
  2558.                 { Handles the staggering of windows as they are opened. }
  2559.  
  2560.                 FUNCTION TWindow.GetGrafPort: GrafPtr; OVERRIDE;
  2561.                 { Returns the windows GrafPtr. }
  2562.  
  2563.                 PROCEDURE TWindow.GetGlobalBounds(VAR globalBounds: Rect);
  2564.                 { Returns a rectangle that is the global bounds of the window. }
  2565.  
  2566.                 FUNCTION TWindow.GetMaxIntersectedDevice(VAR screenRect: Rect): GDHandle;
  2567.                 { Returns the screenRect of the most intersected device & its GDHandle, or
  2568.                   if CQD isn't available it returns GetGrayRgn intersected with screenbits.bounds
  2569.                   and NIL for the GDHandle. }
  2570.  
  2571.                 FUNCTION TWindow.GetWindow: TWindow; OVERRIDE;
  2572.                 { Returns SELF. }
  2573.  
  2574.                 PROCEDURE TWindow.SetResizeLimits(itsMinSize, itsMaxSize: Point);
  2575.                 { Used to set the limits to which the window can be resized. }
  2576.  
  2577.                 PROCEDURE TWindow.SetTarget(newTarget: TEvtHandler);
  2578.                 { Set fTarget to 'newTarget' and if we are the active window then call
  2579.                 gApplication.SetTarget. }
  2580.  
  2581.                 PROCEDURE TWindow.InstallDocument(itsDocument: TDocument);
  2582.                 { Sets our fDocument field to 'itsDocument' and then installs the SELF in the
  2583.                 document, if the document is not NIL. }
  2584.  
  2585.                 FUNCTION TWindow.IsDraggable(whichRect: Rect): BOOLEAN;
  2586.                 { Returns TRUE if any of the corner points of whichRect are draggable. }
  2587.  
  2588.                 FUNCTION TWindow.BuildWindowRgns(build: BOOLEAN): BOOLEAN;
  2589.                 { IF build=kBuild THEN ensures that the window regions are valid; sets
  2590.                 fContRgnInset, fContDifference.
  2591.                 Cleans up if necessary, when done with window regions.
  2592.                 Returns the old state of the window regions. }
  2593.  
  2594.                 { Inspecting Methods }
  2595.  
  2596.                 PROCEDURE TWindow.Fields(PROCEDURE DoToField(fieldName: Str255;
  2597.                                                              fieldAddr: Ptr;
  2598.                                                              fieldType: INTEGER)); OVERRIDE;
  2599.                 { Used by the Inspector and the Debugger to display the contents of this class's
  2600.                 fields. }
  2601.  
  2602.                 PROCEDURE TWindow.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  2603.                 { Used by the Inspector to get the name of this class. }
  2604.  
  2605.                 END;
  2606.  
  2607. {--------------------------------------------------------------------------------------------------}
  2608.             ControlTemplate     = PACKED RECORD
  2609.                 itsAdornment:        CntlAdornment;
  2610.                 filler1:            Byte;
  2611.                 itsPenSize:         Point;
  2612.                 isSizable:            BOOLEAN;
  2613.                 isDimmed:            BOOLEAN;
  2614.                 isHilited:            BOOLEAN;
  2615.                 canDismiss:         BOOLEAN;
  2616.                 filler2:            0..4095;
  2617.                 itsInset:            Rect;
  2618.                 itsTextFace:        Style;
  2619.                 itsTextSize:        INTEGER;
  2620.                 itsTextColor:        RGBColor;
  2621.                 itsFontName:        Str255;             {Actually a variable length P-String}
  2622.                 END;
  2623.             ControlTemplatePtr    = ^ControlTemplate;
  2624.  
  2625.             TControl            = OBJECT (TView)        { An abstract class that represents a
  2626.                                                          control. }
  2627.                 fDefChoice:         INTEGER;            { the choice to automatically pass up the
  2628.                                                          line via DoChoice }
  2629.                 fHilite:            BOOLEAN;            { is this view hilited }
  2630.                 fDimmed:            BOOLEAN;            { is this view dimmed }
  2631.                 fSizeable:            BOOLEAN;            { is the control portion of this view
  2632.                                                          sizeable }
  2633.                 fDismissesDialog:    BOOLEAN;            { can this view dismiss it's dialogview }
  2634.                 fAdornment:         CntlAdornment;        { the adornment to be drawn in addition to
  2635.                                                          the view }
  2636.                 fPenSize:            Point;                { pen size to be used in adorning }
  2637.                 fInset:             Rect;                { amount to inset the control portion of the
  2638.                                                          view }
  2639.                 fTextStyle:         TextStyle;            { the TextStyle to use when rendering this
  2640.                                                          view }
  2641.  
  2642.                 PROCEDURE TControl.IControl(itsSuperView: TView;
  2643.                                             itsLocation, itsSize: VPoint;
  2644.                                             itsHSizeDet, itsVSizeDet: SizeDeterminer);
  2645.                 { Initialize a control procedurally. }
  2646.  
  2647.                 PROCEDURE TControl.IRes(itsDocument: TDocument;
  2648.                                         itsSuperView: TView;
  2649.                                         VAR itsParams: Ptr); OVERRIDE;
  2650.                 { Initialize a control from a resource template. }
  2651.  
  2652.                 PROCEDURE TControl.WRes(theResource: ViewRsrcHndl;
  2653.                                         VAR itsParams: Ptr); OVERRIDE;
  2654.                 { For writing a control view out to a resource. }
  2655.  
  2656.                 PROCEDURE TControl.WriteRes(theResource: ViewRsrcHndl;
  2657.                                             VAR itsParams: Ptr); OVERRIDE;
  2658.                 { For writing a control view to a resource, works in conjunction with tbe previous
  2659.                 method. }
  2660.  
  2661.                 PROCEDURE TControl.ComputeSize(VAR newSize: VPoint); OVERRIDE;
  2662.                 { Called to compute the control's size. }
  2663.  
  2664.                 FUNCTION TControl.ContainsMouse(theMouse: VPoint): BOOLEAN; OVERRIDE;
  2665.                 { Returns TRUE if 'theMouse is currently in the controls area. }
  2666.  
  2667.                 PROCEDURE TControl.ControlArea(VAR theArea: Rect);
  2668.                 { Returns in 'theArea' the controls active area. }
  2669.  
  2670.                 PROCEDURE TControl.Dim;
  2671.                 { Dims the control by drawing over it with a gray pattern. }
  2672.  
  2673.                 PROCEDURE TControl.DimState(state, redraw: BOOLEAN);
  2674.                 { If we are not currently dimmed then set fDimmed to 'state.and if 'redraw' is TRUE
  2675.                 then call DrawContents. }
  2676.  
  2677.                 FUNCTION TControl.DoMouseCommand(VAR theMouse: Point;
  2678.                                                  VAR info: EventInfo;
  2679.                                                  VAR hysteresis: Point): TCommand; OVERRIDE;
  2680.                 { Creates a control tracker command, which is returned. }
  2681.  
  2682.                 PROCEDURE TControl.Draw(area: Rect); OVERRIDE;
  2683.                 { Calls Adorn to handle any adornments and the Dim & Hilite if required. }
  2684.  
  2685.                 FUNCTION TControl.Focus: BOOLEAN; OVERRIDE;
  2686.                 { Calls inherited Focus and if its TRUE then sets the port's text style and returns
  2687.                 TRUE, if it can't be focused returns FALSE. }
  2688.  
  2689.                 PROCEDURE TControl.Flash;
  2690.                 { Causes a control to flash with an 8 tick delay. }
  2691.  
  2692.                 PROCEDURE TControl.Hilite;
  2693.                 { Hilites the control by inverting its controlarea. }
  2694.  
  2695.                 PROCEDURE TControl.HiliteState(state, redraw: BOOLEAN);
  2696.                 { If our fHilite is not 'state' the set it to 'state' before calling Hilite. Note:
  2697.                 hilite is only called if 'redraw is TRUE and we can Focus. }
  2698.  
  2699.                 PROCEDURE TControl.Inset(dh, dv: INTEGER;
  2700.                                          redraw: BOOLEAN);
  2701.                 { If we are sizable then offset fInset to 'dh' & 'dv' redrawing if 'redraw' is TRUE.
  2702.                 }
  2703.  
  2704.                 FUNCTION TControl.IsDimmed: BOOLEAN;
  2705.                 { Returns TRUE if the control is currently dimmed. }
  2706.  
  2707.                 PROCEDURE TControl.SetInset(newInset: Rect;
  2708.                                             redraw: BOOLEAN);
  2709.                 { Set fInset to 'newInset' redrawing if 'redraw' is TRUE. }
  2710.  
  2711.                 PROCEDURE TControl.InstallColor(theColor: RGBColor;
  2712.                                                 redraw: BOOLEAN);
  2713.                 { Sets the color field of our text style record to 'theColor', if 'redraw' then call
  2714.                 DrawContents. }
  2715.  
  2716.                 PROCEDURE TControl.InstallTextStyle(theTextStyle: TextStyle;
  2717.                                                     redraw: BOOLEAN);
  2718.                 { Sets fTextStyle to 'theTextStyle', if 'redraw' then call DrawContents. }
  2719.  
  2720.                 PROCEDURE TControl.Resize(width, height: VCoordinate;
  2721.                                           invalidate: BOOLEAN); OVERRIDE;
  2722.                 { Calls inherited Resize before calling ForceRedraw. }
  2723.  
  2724.                 PROCEDURE TControl.TrackFeedback(anchorPoint, nextPoint: VPoint;
  2725.                                                  turnItOn, mouseDidMove: BOOLEAN); OVERRIDE;
  2726.                 { Doesn't use the default feedback }
  2727.  
  2728.                 PROCEDURE TControl.TrackMouse(aTrackPhase: TrackPhase;
  2729.                                               VAR anchorPoint, previousPoint, nextPoint: VPoint;
  2730.                                               mouseDidMove: BOOLEAN); OVERRIDE;
  2731.                 { Called back from tracking command. Handles tracking of the mouse and then calls
  2732.                 DoChoice on TrackRelease. }
  2733.  
  2734.                 FUNCTION TControl.Validate: LONGINT;
  2735.                 { By default returns 'noErr'. }
  2736.  
  2737.                 PROCEDURE TControl.Fields(PROCEDURE
  2738.                                           DoToField(fieldName: Str255;
  2739.                                                     fieldAddr: Ptr;
  2740.                                                     fieldType: INTEGER)); OVERRIDE;
  2741.                 { Used by the Inspector and the Debugger to display the contents of this class's
  2742.                 fields. }
  2743.  
  2744.                 END;
  2745.  
  2746. {--------------------------------------------------------------------------------------------------}
  2747.             TCtlMgr             = OBJECT (TControl)     { An abstract class that represents a
  2748.                                                          toolbox Control Manager control. }
  2749.                 fCMgrControl:        ControlHandle;        { the Control Manager Control that is being
  2750.                                                          managed }
  2751.                 fBitsToShift:        INTEGER;            { # bits shifted to convert between short
  2752.                                                          and long value. }
  2753.                 fLongVal:            VCoordinate;        { the current value }
  2754.                 fLongMin:            VCoordinate;        { the minimum setting }
  2755.                 fLongMax:            VCoordinate;        { the maximum setting }
  2756.  
  2757.                 PROCEDURE TCtlMgr.ICtlMgr(itsSuperView: TView;
  2758.                                           itsLocation, itsSize: VPoint;
  2759.                                           itsHSizeDet, itsVSizeDet: SizeDeterminer;
  2760.                                           itsTitle: Str255;
  2761.                                           itsVal, itsMin, itsMax: LONGINT;
  2762.                                           itsProcID: INTEGER);
  2763.                 { Initialize procedurally. }
  2764.  
  2765.                 PROCEDURE TCtlMgr.IRes(itsDocument: TDocument;
  2766.                                        itsSuperView: TView;
  2767.                                        VAR itsParams: Ptr); OVERRIDE;
  2768.                 { Initialize from a resource template. }
  2769.  
  2770.                 PROCEDURE TCtlMgr.WriteRes(theResource: ViewRsrcHndl;
  2771.                                            VAR itsParams: Ptr); OVERRIDE;
  2772.                 { For writing a CtlMgr view to a resource. }
  2773.  
  2774.                 PROCEDURE TCtlMgr.Free; OVERRIDE;
  2775.                 { Set the size of control to zero call DisposeControl, then  call inherited Free. }
  2776.  
  2777.                 PROCEDURE TCtlMgr.BeInPort(itsPort: GrafPtr); OVERRIDE;
  2778.                 { Sets the control to be in 'itsPort', by setting the contrlOwner field of the
  2779.                 ControlHandle. }
  2780.  
  2781.                 PROCEDURE TCtlMgr.CreateCMgrControl(itsBounds: Rect;
  2782.                                                     itsTitle: Str255;
  2783.                                                     itsVal, itsMin, itsMax: LONGINT;
  2784.                                                     itsProcID: INTEGER);
  2785.                 { Used to create a new control, calls NewControl to create the control. }
  2786.  
  2787.                 PROCEDURE TCtlMgr.DimState(state, redraw: BOOLEAN); OVERRIDE;
  2788.                 { Set the dim state to 'state' and redrawing it if 'redraw'. }
  2789.  
  2790.                 FUNCTION TCtlMgr.DoMouseCommand(VAR theMouse: Point;
  2791.                                                 VAR info: EventInfo;
  2792.                                                 VAR hysteresis: Point): TCommand; OVERRIDE;
  2793.                 { Handles mouse downs in the control by calling TestControl and DoChoice, returns
  2794.                 NIL. }
  2795.  
  2796.                 PROCEDURE TCtlMgr.Draw(area: Rect); OVERRIDE;
  2797.                 { Draws the control by calling the toolbox routine ShowControl. }
  2798.  
  2799.                 { Methods to manipulate the TCtlMgr values }
  2800.                 FUNCTION TCtlMgr.GetLongMax: VCoordinate;
  2801.                 { Returns the current fLongMax value. }
  2802.  
  2803.                 FUNCTION TCtlMgr.GetLongMin: VCoordinate;
  2804.                 { Returns the current fLongMin value. }
  2805.  
  2806.                 FUNCTION TCtlMgr.GetLongVal: VCoordinate;
  2807.                 { Returns the current fLongVal value. }
  2808.  
  2809.                 PROCEDURE TCtlMgr.SetLongMax(itsMax: VCoordinate;
  2810.                                                 redraw: BOOLEAN);
  2811.                 { Sets fLongMax to 'itsMax', redrawing if required. }
  2812.  
  2813.                 PROCEDURE TCtlMgr.SetLongMin(itsMin: VCoordinate;
  2814.                                                 redraw: BOOLEAN);
  2815.                 { Sets flongMin to 'itsMin', redrawing if required. }
  2816.  
  2817.                 PROCEDURE TCtlMgr.SetLongVal(itsVal: VCoordinate;
  2818.                                                 redraw: BOOLEAN);
  2819.                 { Sets fLongVal to 'itsVal' redrawing if required. }
  2820.  
  2821.                 PROCEDURE TCtlMgr.SetLongValues(itsVal, itsMin, itsMax: VCoordinate;
  2822.                                                    redraw: BOOLEAN);
  2823.                 { Sets all of the values at once, redrawing if required. }
  2824.  
  2825.                 { Methods to manipulate the Control Manager control values }
  2826.                 FUNCTION TCtlMgr.GetMax: INTEGER;
  2827.                 { Returns the maximum value of the Control Manager control. }
  2828.  
  2829.                 FUNCTION TCtlMgr.GetMin: INTEGER;
  2830.                 { Returns the minimum value of the Control Manager control. }
  2831.  
  2832.                 PROCEDURE TCtlMgr.GetText(VAR theText: Str255);
  2833.                 { Returns the controls title, if any. }
  2834.  
  2835.                 FUNCTION TCtlMgr.GetVal: INTEGER;
  2836.                 { Returns the current value of the Control Manager control. }
  2837.  
  2838.                 PROCEDURE TCtlMgr.SetMax(itsMax: INTEGER;
  2839.                                          redraw: BOOLEAN);
  2840.                 { While focused sets the maximum value of the Control Manager control to 'itsMax'. }
  2841.  
  2842.                 PROCEDURE TCtlMgr.SetMin(itsMin: INTEGER;
  2843.                                          redraw: BOOLEAN);
  2844.                 { While focused sets the minimum value of the Control Manager control to 'itsMin'. }
  2845.  
  2846.                 PROCEDURE TCtlMgr.SetText(itsText: Str255;
  2847.                                           redraw: BOOLEAN);
  2848.                 { Sets the controls title to 'itsText', redrawing if required. }
  2849.  
  2850.                 PROCEDURE TCtlMgr.SetVal(newVal: INTEGER;
  2851.                                          redraw: BOOLEAN);
  2852.        { While focused sets the Control Manager controls value to 'newVal', redrawing if required. }
  2853.  
  2854.                 PROCEDURE TCtlMgr.SetValues(itsVal, itsMin, itsMax: INTEGER;
  2855.                                             redraw: BOOLEAN);
  2856. { While focused sets all the values of the Control Manager control, at once, redrawing if required. }
  2857.  
  2858.                 PROCEDURE TCtlMgr.HiliteState(state, redraw: BOOLEAN); OVERRIDE;
  2859.                 { Set the hilite state to 'state', redrawing if required.If hilite state is currently
  2860.                 'state' then does nothing. }
  2861.  
  2862.                 FUNCTION TCtlMgr.IsCMgrVisible: BOOLEAN;
  2863.                 { Returns TRUE if the control is currently visible, FALSE if not. }
  2864.  
  2865.                 PROCEDURE TCtlMgr.Resize(width, height: VCoordinate;
  2866.                                          invalidate: BOOLEAN); OVERRIDE;
  2867.                 { If the control is resizable calls the toolbox routines MoveControl & SizeControl
  2868.                 before calling inherited Resize. }
  2869.  
  2870.                 PROCEDURE TCtlMgr.SetCMgrVisibility(beVisible: BOOLEAN);
  2871.                 { Sets the visibility of the control to 'isVisible'. }
  2872.  
  2873.                 PROCEDURE TCtlMgr.WhileFocused(PROCEDURE DoToControl;
  2874.                                                redraw: BOOLEAN);
  2875.                 { While focused call "DoToControl", redrawing if required. }
  2876.  
  2877.                 PROCEDURE TCtlMgr.Fields(PROCEDURE DoToField(fieldName: Str255;
  2878.                                                              fieldAddr: Ptr;
  2879.                                                              fieldType: INTEGER)); OVERRIDE;
  2880.                 { Used by the Inspector and the Debugger to display the contents of this class's
  2881.                 fields. }
  2882.                 END;
  2883.  
  2884. {--------------------------------------------------------------------------------------------------}
  2885.             ScrollBarTemplate    = RECORD
  2886.                 value:                LONGINT;
  2887.                 minimum:            LONGINT;
  2888.                 maximum:            LONGINT;
  2889.                 END;
  2890.             ScrollBarTemplatePtr = ^ScrollBarTemplate;
  2891.  
  2892.             TScrollBar            = OBJECT (TCtlMgr)        { A subclass of TCtlMgr that maps between
  2893.                                                          longint values for our view coordinates
  2894.                                                          and the integers of a toolbox scrollbar. }
  2895.                 fDirection:         VHSelect;            { is this a horizontal or vertical scrollbar
  2896.                                                          }
  2897.  
  2898.                 PROCEDURE TScrollBar.IScrollBar(itsSuperView: TView;
  2899.                                                 itsLocation, itsSize: VPoint;
  2900.                                                 itsHSizeDet, itsVSizeDet: SizeDeterminer;
  2901.                                                 itsDirection: VHSelect;
  2902.                                                 itsVal, itsMin, itsMax: LONGINT);
  2903.                 { Initialize a scrollbar procedurally. }
  2904.  
  2905.                 PROCEDURE TScrollBar.IRes(itsDocument: TDocument;
  2906.                                           itsSuperView: TView;
  2907.                                           VAR itsParams: Ptr); OVERRIDE;
  2908.                 { Initialize a scrollbar from a resource template. }
  2909.  
  2910.                 PROCEDURE TScrollBar.WRes(theResource: ViewRsrcHndl;
  2911.                                           VAR itsParams: Ptr); OVERRIDE;
  2912.                 { For writing a dialog view out to a resource. }
  2913.  
  2914.                 PROCEDURE TScrollBar.WriteRes(theResource: ViewRsrcHndl;
  2915.                                               VAR itsParams: Ptr); OVERRIDE;
  2916.                 { For writing a scrollbar to a resource, works in conjunction with tbe previous
  2917.                 method. }
  2918.  
  2919.                 PROCEDURE TScrollBar.DeltaValue(delta: VCoordinate);
  2920.                 { Does range checking on 'delta' checking it against fLongMin & fLongMax for the
  2921.                 scrollbar. }
  2922.  
  2923.                 FUNCTION TScrollBar.DoMouseCommand(VAR theMouse: Point;
  2924.                                                    VAR info: EventInfo;
  2925.                                                    VAR hysteresis: Point): TCommand; OVERRIDE;
  2926.                 { Handles the mouse down in the various parts of the scrollbar. }
  2927.  
  2928.                 PROCEDURE TScrollBar.TrackScrollBar(partCode: INTEGER);
  2929.                 { Tracks the scrollbar by calling DeltaValue. }
  2930.  
  2931.                 PROCEDURE TScrollBar.ActionProc(partCode: INTEGER);
  2932.                 { Forwarded to from the global routine: ActionProcForTScrollBar which was set as the
  2933.                 ScrollBar's action proc.  Typically forwards again to TrackScrollBar after bounds
  2934.                 checking and Updates before returning to the ScrollBar. }
  2935.  
  2936.                 { Inspecting }
  2937.  
  2938.                 PROCEDURE TScrollBar.Fields(PROCEDURE
  2939.                                             DoToField(fieldName: Str255;
  2940.                                                       fieldAddr: Ptr;
  2941.                                                       fieldType: INTEGER)); OVERRIDE;
  2942.                 { Used by the Inspector and the Debugger to display the contents to this class's
  2943.                 fields. }
  2944.                 END;
  2945.  
  2946. {--------------------------------------------------------------------------------------------------}
  2947.             TSScrollBar         = OBJECT (TScrollBar)    { A subclass of TScrollBar that is
  2948.                                                          associated with one or more scrollers. }
  2949.                 fScrollers:         TList;                { the associated scrollers if any }
  2950.  
  2951.                 PROCEDURE TSScrollBar.ISScrollBar(itsSuperView: TView;
  2952.                                                   itsLocation, itsSize: VPoint;
  2953.                                                   itsHSizeDet, itsVSizeDet: SizeDeterminer;
  2954.                                                   itsDirection: VHSelect;
  2955.                                                   itsMax: LONGINT;
  2956.                                                   itsScroller: TScroller);
  2957.                 { Initialize the scrollbar procedurally. }
  2958.  
  2959.                 PROCEDURE TSScrollBar.IRes(itsDocument: TDocument;
  2960.                                            itsSuperView: TView;
  2961.                                            VAR itsParams: Ptr); OVERRIDE;
  2962.                 { Initialize the scrollbar from a resource template. }
  2963.  
  2964.                 PROCEDURE TSScrollBar.WriteRes(theResource: ViewRsrcHndl;
  2965.                                                VAR itsParams: Ptr); OVERRIDE;
  2966.                 { For writing an sscrollbar out to a resource. }
  2967.  
  2968.                 PROCEDURE TSScrollBar.Free; OVERRIDE;
  2969.                 { If the scrollers are not NIL then first detach the scrollbars from them before
  2970.                 freeing the scrollers, then call inherited Free. }
  2971.  
  2972.                 PROCEDURE TSScrollBar.AttachScroller(itsScroller: TScroller);
  2973.                 { IF 'itsScroller' is not NIL then add it to our list and attach ourselves to it. }
  2974.  
  2975.                 PROCEDURE TSScrollBar.BeInPort(itsPort: GrafPtr); OVERRIDE;
  2976.                 { Call inherited BeInPort and then set our visibility based on the state of the
  2977.                 window we are in. }
  2978.  
  2979.                 PROCEDURE TSScrollBar.Activate(entering: BOOLEAN); OVERRIDE;
  2980.                 { If 'entering' is TRUE then show ourselves, otherwise just call Draw to frame our
  2981.                 area. }
  2982.  
  2983.                 FUNCTION TSScrollBar.DoMouseCommand(VAR theMouse: Point;
  2984.                                                     VAR info: EventInfo;
  2985.                                                     VAR hysteresis: Point): TCommand; OVERRIDE;
  2986.                 { Handles mouse downs in the scrollbar. }
  2987.  
  2988.                 PROCEDURE TSScrollBar.Draw(area: Rect); OVERRIDE;
  2989.                 { Draws a frame around the controls area before calling inherited Draw. }
  2990.  
  2991.                 PROCEDURE TSScrollBar.TrackScrollBar(partCode: INTEGER); OVERRIDE;
  2992.                 { Called to handle tracking of the scrollbar by calling DeltaValue. }
  2993.  
  2994.                 { Inspecting }
  2995.  
  2996.                 PROCEDURE TSScrollBar.Fields(PROCEDURE
  2997.                                              DoToField(fieldName: Str255;
  2998.                                                        fieldAddr: Ptr;
  2999.                                                        fieldType: INTEGER)); OVERRIDE;
  3000.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3001.                 fields. }
  3002.                 END;
  3003.  
  3004. {--------------------------------------------------------------------------------------------------}
  3005.             TDeskScrapView        = OBJECT (TView)        { The default view in the Clipboard, able to
  3006.                                                          display only standard text and pictures. }
  3007.                 fHavePicture:        BOOLEAN;            { are we holding a PICT }
  3008.                 fHaveText:            BOOLEAN;            { is there any TEXT }
  3009.                 fScrapCount:        INTEGER;            { scrapCount of the scrap represented by
  3010.                                                          this view.}
  3011.  
  3012.                 fDataHandle:        Handle;             { if non-NIL, will be either a PicHandle to
  3013.                                                          my picture or a Handle to my Text }
  3014.  
  3015.                 PROCEDURE TDeskScrapView.IDeskScrapView;
  3016.                 { Initialize the deskscrap view procedurally. }
  3017.  
  3018.                 PROCEDURE TDeskScrapView.IRes(itsDocument: TDocument;
  3019.                                               itsSuperView: TView;
  3020.                                               VAR itsParams: Ptr); OVERRIDE;
  3021.                 { Initialize the deskscrap view from a resource template. }
  3022.  
  3023.                 PROCEDURE TDeskScrapView.Free; OVERRIDE;
  3024.                 { Does nothing, don't ever want to free gClipOrphange. }
  3025.  
  3026.                 PROCEDURE TDeskScrapView.CheckScrapContents;
  3027.                 { Checks the contents of the deskscrap. }
  3028.  
  3029.                 PROCEDURE TDeskScrapView.CalcMinSize(VAR minSize: VPoint); OVERRIDE;
  3030.                 { Responsible for calculating the correct size for the deskscrap view. }
  3031.  
  3032.                 PROCEDURE TDeskScrapView.Draw(area: Rect); OVERRIDE;
  3033.                 { handles the drawing of the contents of the deskscrap, which by default is either a
  3034.                 PICT or text. }
  3035.  
  3036.                 PROCEDURE TDeskScrapView.SuperViewChangedSize(delta: VPoint;
  3037.                                                               invalidate: BOOLEAN); OVERRIDE;
  3038.                 { If our superview changes size then call AdjustSize & ForceRedraw. }
  3039.  
  3040.                 PROCEDURE TDeskScrapView.WriteToDeskScrap; OVERRIDE;
  3041.                 { This view represents data that is already written to the deskscrap, so this does
  3042.                 nothing. }
  3043.  
  3044.                 { Inspecting }
  3045.                 PROCEDURE TDeskScrapView.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  3046.                 { Used by the Inspector to get the name of this class. }
  3047.  
  3048.                 PROCEDURE TDeskScrapView.Fields(PROCEDURE
  3049.                                                 DoToField(fieldName: Str255;
  3050.                                                           fieldAddr: Ptr;
  3051.                                                           fieldType: INTEGER)); OVERRIDE;
  3052.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3053.                 fields. }
  3054.  
  3055.                 END;
  3056.  
  3057. {--------------------------------------------------------------------------------------------------}
  3058.             TPrintHandler        = OBJECT (TEvtHandler)    { Handles printing at a specified resolution
  3059.                                                          on behalf of a view. This class is really
  3060.                                                          a non-functional stub for programs that
  3061.                                                          don't use the printing building block. }
  3062.                 fView:                TView;                { The view whose printing is handled }
  3063.                 fDocument:            TDocument;            { the document printed by this handler }
  3064.                 fDeviceRes:         Point;                { formal printer resolution, spots per inch
  3065.                                                          }
  3066.                 fViewPerPage:        VPoint;             { The amount of the view that is visible on
  3067.                                                          a page }
  3068.                 fFocusedPage:        INTEGER;            { The page number currently focused }
  3069.  
  3070.                                 { Initialization and termination }
  3071.  
  3072.                 PROCEDURE TPrintHandler.IPrintHandler(itsView: TView);
  3073.                 { Initialize the printHandler, and associate it and 'itsView' with each other }
  3074.  
  3075.                 PROCEDURE TPrintHandler.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
  3076.                 { Used by the inspector to get the name of this class. }
  3077.  
  3078.                 PROCEDURE TPrintHandler.Fields(PROCEDURE
  3079.                                                DoToField(fieldName: Str255;
  3080.                                                          fieldAddr: Ptr;
  3081.                                                          fieldType: INTEGER)); OVERRIDE;
  3082.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3083.                 fields. }
  3084.  
  3085.                 PROCEDURE TPrintHandler.FocusOnInterior;
  3086.                 { Stub }
  3087.  
  3088.                 PROCEDURE TPrintHandler.SetDefaultPrintInfo;
  3089.                 { Stub }
  3090.  
  3091.                 { Printing-related reformatting and computations }
  3092.  
  3093.                 FUNCTION TPrintHandler.BreakFollowing(vhs: VHSelect;
  3094.                                                       prevBreak: VCoordinate;
  3095.                                                       VAR automatic: BOOLEAN): VCoordinate;
  3096.                 { Returns the location of the page break which follows the page break located at
  3097.                 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
  3098.                 thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
  3099.                 page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
  3100.                 horizontal lines }
  3101.  
  3102.                 PROCEDURE TPrintHandler.CalcPageStrips(VAR pageStrips: Point);
  3103.                 { Recalculate the number of strips of pages in each dimension }
  3104.  
  3105.                 PROCEDURE TPrintHandler.CalcViewPerPage(VAR amtPerPage: VPoint);
  3106.                { Computes the amount of view, in each dimension, to be allocated to a printed page }
  3107.  
  3108.                 PROCEDURE TPrintHandler.CheckPrinter;
  3109.                 { See if there are changed printer-configuration parameters which need to be
  3110.                 absorbed, and if so, absorb them }
  3111.  
  3112.                 PROCEDURE TPrintHandler.LocatePageInterior(pageNumber: INTEGER;
  3113.                                                            VAR loc: Point);
  3114.                 { Decide where the top-left-most point of the the interior of the page should be }
  3115.  
  3116.                 PROCEDURE TPrintHandler.PrinterChanged;
  3117.                 { The metrics relating to printer use have changed; absorb the information and react
  3118.                 }
  3119.  
  3120.                 PROCEDURE TPrintHandler.RedoPageBreaks;
  3121.                 { Recompute the dividing lines between areas of the view which will be mapped into
  3122.                 different printed pages }
  3123.  
  3124.                 PROCEDURE TPrintHandler.Reset;
  3125.                 { Resets the print handler to the default values }
  3126.  
  3127.                 { Printing-related commands }
  3128.  
  3129.                 FUNCTION TPrintHandler.Print(itsCmdNumber: CmdNumber;
  3130.                                              VAR proceed: BOOLEAN): TCommand; {+}
  3131.                 { By default sets 'proceed' to TRUE and returns NIL. }
  3132.  
  3133.                 FUNCTION TPrintHandler.SetupForFinder: BOOLEAN;
  3134.                 { Intended to set up the print handler for finder printing. }
  3135.  
  3136.                 { Printing-related screen feedback }
  3137.  
  3138.                 PROCEDURE TPrintHandler.DrawPrintFeedback(area: Rect);
  3139.                 { Draw page-breaks, page-numbers, view-borders, rulers, etc. }
  3140.  
  3141.                 PROCEDURE TPrintHandler.DrawPageBreak(vhs: VHSelect;
  3142.                                                       whichBreak: INTEGER;
  3143.                                                       loc: VCoordinate;
  3144.                                                       automatic: BOOLEAN);
  3145.                 { Does nothing. }
  3146.  
  3147.                 { Actual printing }
  3148.  
  3149.                 FUNCTION TPrintHandler.MaxPageNumber: INTEGER;
  3150.                 { Returns the largest page number which could be reasonably printed, given the
  3151.                 properties of the view; in cases like a SpreadSheet, this is not necessarily as
  3152.                 large as the product (row strips) x (column strips) }
  3153.  
  3154.                 PROCEDURE TPrintHandler.SetPageInterior(pageNumber: INTEGER);
  3155.                 { Set up the pad-space Interior rectangle for the given page number }
  3156.  
  3157.                 PROCEDURE TPrintHandler.SetPageOffset(coord: VPoint);
  3158.                 { Given the view coordinates of the top-left-most point of the view which is being
  3159.                 mapped into the current page (in coord), this method's job is to compute the
  3160.                 correct fRelOrigin field for the current page }
  3161.  
  3162.                 END;
  3163.  
  3164. {--------------------------------------------------------------------------------------------------}
  3165.             TCommand            = OBJECT (TObject)        { Handles a user command, including undoing
  3166.                                                          and mouse-tracking if required. Usually
  3167.                                                          created by the part of the Application
  3168.                                                          with the greatest specific knowledge about
  3169.                                                          the action to take in response to events
  3170.                                                          and passed back to be performed at several
  3171.                                                          well defined places.}
  3172.                 fCmdNumber:         CmdNumber;            { Can be a many-to-one mapping of fCmdNumber
  3173.                                                          to TCommand }
  3174.                 fView:                TView;                { The view affected by this command, and in
  3175.                                                          which tracking takes place, if any. }
  3176.                 fChangedDocument:    TDocument;            { the document changed by this command }
  3177.                 fCmdDone:            BOOLEAN;            { TRUE if the last "execution" message sent
  3178.                                                          to the command was DoIt or RedoIt }
  3179.                 fCanUndo:            BOOLEAN;            { Defaults to TRUE }
  3180.                 fCausesChange:        BOOLEAN;            { Defaults to TRUE; Marks document changed
  3181.                                                          when command is done }
  3182.                 fChangesClipboard:    BOOLEAN;            { Defaults to FALSE. Set to true for command
  3183.                                                          subclasses representing CUT and/ or COPY
  3184.                                                          commands which change the Clipboard. }
  3185.                 fFreeOnCompletion:    BOOLEAN;            { TRUE to cause the command to be freed on
  3186.                                                          completion (the default). Completion is
  3187.                                                          after DoIt for non-undoable commands and
  3188.                                                          Commit for undoable commands. }
  3189.                 fPriority:            CommandPriority;    { How this command should be prioritized if
  3190.                                                          it has do compete on a prioritized basis
  3191.                                                          for execution. kNormalPriority is the
  3192.                                                          Default. Most programs won't have to mess
  3193.                                                          with this. }
  3194.                 fReadyToExecute:    BOOLEAN;            { TRUE (the default) will enable this
  3195.                                                          command to be returned from any queues
  3196.                                                          that may be holding it. Most programs
  3197.                                                          won't have to mess with this. }
  3198.                 fRecurring:            BOOLEAN;            { FALSE (the default) will enable this
  3199.                                                          command to be removed from any command
  3200.                                                          queue that holds it because it is only
  3201.                                                          executed once. }
  3202.                 { The remaining fields are for command objects that track the mouse.
  3203.                 A future version of MacApp will have probably have Trackers as a subclass of TCommand.
  3204.                 Left now for compatibility (2.0) }
  3205.                 fTracksMouse:        BOOLEAN;            { TRUE if the command should be tracked. }
  3206.                 fInitialPt:         Point;                { Where to track from (usually where the
  3207.                                                          mouse went down) in global coordinates.
  3208.                                                          MacApp sets this field in
  3209.                                                          TApplication.HandleMooseDown, you set it
  3210.                                                          if you create trackers that don't get
  3211.                                                          passed back up through that call chain. }
  3212.  
  3213.                 fConstrainsMouse:    BOOLEAN;            { Defaults to FALSE; if you set to TRUE then
  3214.                                                          TrackConstrain will be called to constrain
  3215.                                                          the mouse. }
  3216.                 fViewConstrain:     BOOLEAN;            { Defaults to TRUE, which means constrain
  3217.                                                          mouse to view limits }
  3218.                 fTrackNonMovement:    BOOLEAN;            { Defaults to FALSE, which means don't track
  3219.                                                          mouse unless it moves. }
  3220.                 fScroller:            TScroller;            { The scroller that handles auto-scrolling }
  3221.  
  3222.                                 { Init & Free }
  3223.                 PROCEDURE TCommand.ICommand(itsCmdNumber: CmdNumber;
  3224.                                             itsDocument: TDocument;
  3225.                                             itsView: TView;
  3226.                                             itsScroller: TScroller);
  3227.                 { Initialize a command procedurally. }
  3228.  
  3229.                 { Inspecting }
  3230.                 PROCEDURE TCommand.Fields(PROCEDURE
  3231.                                           DoToField(fieldName: Str255;
  3232.                                                     fieldAddr: Ptr;
  3233.                                                     fieldType: INTEGER)); OVERRIDE;
  3234.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3235.                 fields. }
  3236.  
  3237.                 { command processing - usually overridden }
  3238.  
  3239.                 PROCEDURE TCommand.Commit;
  3240.                 { Stub }
  3241.  
  3242.                 PROCEDURE TCommand.DoIt;
  3243.                 { Stub }
  3244.  
  3245.                 PROCEDURE TCommand.RedoIt;
  3246.                 { Stub }
  3247.  
  3248.                 PROCEDURE TCommand.UndoIt;
  3249.                 { Stub }
  3250.  
  3251.                 { Scheduling }
  3252.                 FUNCTION TCommand.IsReadyToExecute: BOOLEAN;
  3253.                 { Returns TRUE (the Default) when the command is ready to execute.    Override to base
  3254.                 the execution of the command on more sophisticated criteria.
  3255.                 Most programs won't have to mess with this.. }
  3256.  
  3257.                 { Mouse Tracking }
  3258.  
  3259.                 FUNCTION TCommand.IsDoneTracking: BOOLEAN;
  3260.                 { Indicates whether the Command is through tracking.  (the command is also through
  3261.                 tracking if you return NIL from TrackMouse).  Defaults to fView.IsDoneTracking.
  3262.                 Most programs won't have to mess with this.
  3263.                 NOTE you still have to deal with queued events if you change the criteria for TRUE. }
  3264.  
  3265.                 PROCEDURE TCommand.TrackConstrain(anchorPoint, previousPoint: VPoint;
  3266.                                                   VAR nextPoint: VPoint);
  3267.                 { Override this if you want to constrain the mouse point to a grid, force drawing a
  3268.                 square, etc. This is called only if fConstrainsMouse is TRUE. }
  3269.  
  3270.                 PROCEDURE TCommand.TrackFeedback(anchorPoint, nextPoint: VPoint;
  3271.                                                  turnItOn, mouseDidMove: BOOLEAN);
  3272.                 { Default is: IF NOT mouseDidMove THEN FrameRect(<rect formed by anchorPoint and
  3273.                 nextPoint>). Before this is called the pen is set to PenNormal and the PenMode to
  3274.                 PatXOR. }
  3275.  
  3276.                 FUNCTION TCommand.TrackMouse(aTrackPhase: TrackPhase;
  3277.                                              VAR anchorPoint, previousPoint, nextPoint: VPoint;
  3278.                                              mouseDidMove: BOOLEAN): TCommand;
  3279.                 { This does the mouse tracking. The default returns SELF. Override it to force
  3280.                 gridding, to return a different type of command, or to perform the command on mouse
  3281.                 release instead of using the usual DoIt approach. All points are in local
  3282.                 coordinates. If aTrackPhase = trackPress then all 3 points will be the same. If
  3283.                 aTrackPhase = trackRelease then nextPoint will be the coordinate in the mouseUp
  3284.                 event (if a mouseUp event is found), otherwise the same point as previousPoint.
  3285.                 Generally, you will ignore nextPoint and just look at previousPoint. mouseDidMove
  3286.                 will be TRUE if aTrackPhase = trackPress or trackRelease; otherwise, it will
  3287.                 indicate if nextPoint = previousPoint. If you change anchorPoint, the new value
  3288.                 will be passed to you next time. The value of nextPoint at the time the routine
  3289.                 exits will be passed to you as previousPoint the next time the routine is called.
  3290.                 You can change nextPoint if you wish. Usually, however, you will do gridding in the
  3291.                 TrackConstrain method. }
  3292.  
  3293.                 PROCEDURE TCommand.AutoScroll(deltaH, deltaV: VCoordinate);
  3294.                 { Implements autoscrolling by calling fScroller.ScrollBy. }
  3295.  
  3296.                 END;
  3297.  
  3298. {--------------------------------------------------------------------------------------------------}
  3299.             TNoChangesCommand    = OBJECT (TCommand)     { Doesn't "change" the document and is not
  3300.                                                          itself undoable. Thus it doesn't flush the
  3301.                                                          last command that did. Useful for
  3302.                                                          deferring actions out to the
  3303.                                                          PerformCommand bottleneck where the stack
  3304.                                                          is unwound and the heap is unloaded for
  3305.                                                          maximum elbow room. }
  3306.                 PROCEDURE TNoChangesCommand.INoChangesCommand(itsCmdNumber: CmdNumber;
  3307.                                                               itsDocument: TDocument;
  3308.                                                               itsView: TView;
  3309.                                                               itsScroller: TScroller);
  3310.  
  3311.                 PROCEDURE TNoChangesCommand.Fields(PROCEDURE
  3312.                                                    DoToField(fieldName: Str255;
  3313.                                                              fieldAddr: Ptr;
  3314.                                                              fieldType: INTEGER)); OVERRIDE;
  3315.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3316.                 fields. }
  3317.  
  3318.                 END;
  3319.  
  3320. {--------------------------------------------------------------------------------------------------}
  3321.             TControlTracker     = OBJECT (TNoChangesCommand) { a command adapted for tracking
  3322.                                                               controls. }
  3323.                 fControl:            TControl;            { the object of our desire }
  3324.  
  3325.                 PROCEDURE TControlTracker.IControlTracker(theControl: TControl);
  3326.                 { Initialize the tracker procedurally. }
  3327.  
  3328.                 { Inspecting }
  3329.                 PROCEDURE TControlTracker.Fields(PROCEDURE
  3330.                                                  DoToField(fieldName: Str255;
  3331.                                                            fieldAddr: Ptr;
  3332.                                                            fieldType: INTEGER)); OVERRIDE;
  3333.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3334.                 fields. }
  3335.  
  3336.                 END;
  3337.  
  3338. {--------------------------------------------------------------------------------------------------}
  3339.             { commands that are created in response to common operations and will forward to the
  3340.             appropriate action }
  3341.  
  3342.             {$IFC qDebug}
  3343.             TDebugCommand        = OBJECT (TNoChangesCommand) { Causes the MacApp Debugger to be
  3344.                                                               entered }
  3345.                 PROCEDURE TDebugCommand.IDebugCommand(itsCmdNumber: CmdNumber);
  3346.                 { Initialize the DebugCommand procedurally. }
  3347.  
  3348.                 PROCEDURE TDebugCommand.DoIt; OVERRIDE;
  3349.                 { Cause the MacApp Debugger to be entered }
  3350.  
  3351.                 PROCEDURE TDebugCommand.Fields(PROCEDURE
  3352.                                                DoToField(fieldName: Str255;
  3353.                                                          fieldAddr: Ptr;
  3354.                                                          fieldType: INTEGER)); OVERRIDE;
  3355.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3356.                 fields. }
  3357.  
  3358.                 END;
  3359.             {$ENDC}
  3360.  
  3361. {--------------------------------------------------------------------------------------------------}
  3362.             {$IFC qInspector}
  3363.             TInspectorCommand    = OBJECT (TNoChangesCommand) { Tells the inspector to make a new
  3364.                                                               window }
  3365.                 PROCEDURE TInspectorCommand.IInspectorCommand(itsCmdNumber: CmdNumber);
  3366.                 { Initialize the DebugCommand procedurally. }
  3367.  
  3368.                 PROCEDURE TInspectorCommand.DoIt; OVERRIDE;
  3369.                 { Tell the inspector to make a new window }
  3370.  
  3371.                 PROCEDURE TInspectorCommand.Fields(PROCEDURE
  3372.                                                    DoToField(fieldName: Str255;
  3373.                                                              fieldAddr: Ptr;
  3374.                                                              fieldType: INTEGER)); OVERRIDE;
  3375.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3376.                 fields. }
  3377.  
  3378.                 END;
  3379.             {$ENDC}
  3380.  
  3381. {--------------------------------------------------------------------------------------------------}
  3382.             TNewDocCommand        = OBJECT (TNoChangesCommand) { Tells the application open a new
  3383.                                                               document. }
  3384.                 PROCEDURE TNewDocCommand.INewDocCommand(itsCmdNumber: CmdNumber);
  3385.                 { Initialize the NewDocCommand procedurally. }
  3386.  
  3387.                 PROCEDURE TNewDocCommand.DoIt; OVERRIDE;
  3388.                 { tell the application open a new document. }
  3389.  
  3390.                 PROCEDURE TNewDocCommand.Fields(PROCEDURE
  3391.                                                 DoToField(fieldName: Str255;
  3392.                                                           fieldAddr: Ptr;
  3393.                                                           fieldType: INTEGER)); OVERRIDE;
  3394.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3395.                 fields. }
  3396.  
  3397.                 END;
  3398.  
  3399. {--------------------------------------------------------------------------------------------------}
  3400.             TOldDocCommand        = OBJECT (TNoChangesCommand) { Tells the application to open an old
  3401.                                                               document. }
  3402.                 PROCEDURE TOldDocCommand.IOldDocCommand(itsCmdNumber: CmdNumber);
  3403.                 { Initialize the OldDocCommand procedurally. }
  3404.  
  3405.                 PROCEDURE TOldDocCommand.DoIt; OVERRIDE;
  3406.                 { tell the application to open an old document. }
  3407.  
  3408.                 PROCEDURE TOldDocCommand.Fields(PROCEDURE
  3409.                                                 DoToField(fieldName: Str255;
  3410.                                                           fieldAddr: Ptr;
  3411.                                                           fieldType: INTEGER)); OVERRIDE;
  3412.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3413.                 fields. }
  3414.  
  3415.                 END;
  3416.  
  3417. {--------------------------------------------------------------------------------------------------}
  3418.             TCloseWindowCommand = OBJECT (TNoChangesCommand) { Tells the application close a window.
  3419.                                                               }
  3420.                 PROCEDURE TCloseWindowCommand.ICloseWindowCommand(itsCmdNumber: CmdNumber;
  3421.                                                                   itsWindow: TWindow);
  3422.                 { Initialize the CloseWindowCommand procedurally. }
  3423.  
  3424.                 PROCEDURE TCloseWindowCommand.DoIt; OVERRIDE;
  3425.                 { tell the application to close a window. }
  3426.  
  3427.                 PROCEDURE TCloseWindowCommand.Fields(PROCEDURE
  3428.                                                      DoToField(fieldName: Str255;
  3429.                                                                fieldAddr: Ptr;
  3430.                                                                fieldType: INTEGER)); OVERRIDE;
  3431.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3432.                 fields. }
  3433.  
  3434.                 END;
  3435.  
  3436. {--------------------------------------------------------------------------------------------------}
  3437.             TQuitCommand        = OBJECT (TNoChangesCommand) { Tells the application to quit. }
  3438.                 PROCEDURE TQuitCommand.IQuitCommand(itsCmdNumber: CmdNumber);
  3439.                 { Initialize the QuitCommand procedurally. }
  3440.  
  3441.                 PROCEDURE TQuitCommand.DoIt; OVERRIDE;
  3442.                 { tell the application to quit. }
  3443.  
  3444.                 PROCEDURE TQuitCommand.Fields(PROCEDURE
  3445.                                               DoToField(fieldName: Str255;
  3446.                                                         fieldAddr: Ptr;
  3447.                                                         fieldType: INTEGER)); OVERRIDE;
  3448.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3449.                 fields. }
  3450.  
  3451.                 END;
  3452.  
  3453. {--------------------------------------------------------------------------------------------------}
  3454.             TUndoRedoCommand    = OBJECT (TNoChangesCommand) { Tells the application to undo/redo
  3455.                                                               the last undoable command }
  3456.                 PROCEDURE TUndoRedoCommand.IUndoRedoCommand(itsCmdNumber: CmdNumber);
  3457.                 { Initialize the UndoRedoCommand procedurally. }
  3458.  
  3459.                 PROCEDURE TUndoRedoCommand.DoIt; OVERRIDE;
  3460.                 { tell the application to undo/redo. }
  3461.                 PROCEDURE TUndoRedoCommand.Fields(PROCEDURE
  3462.                                                   DoToField(fieldName: Str255;
  3463.                                                             fieldAddr: Ptr;
  3464.                                                             fieldType: INTEGER)); OVERRIDE;
  3465.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3466.                 fields. }
  3467.  
  3468.                 END;
  3469.  
  3470. {--------------------------------------------------------------------------------------------------}
  3471.             TAboutAppCommand    = OBJECT (TNoChangesCommand) { Tells the application to show its
  3472.                                                               about box. }
  3473.                 PROCEDURE TAboutAppCommand.IAboutAppCommand(itsCmdNumber: CmdNumber);
  3474.                 { Initialize the AboutAppCommand procedurally. }
  3475.  
  3476.                 PROCEDURE TAboutAppCommand.DoIt; OVERRIDE;
  3477.                 { tell the application to DoShowAboutApp. }
  3478.                 PROCEDURE TAboutAppCommand.Fields(PROCEDURE
  3479.                                                   DoToField(fieldName: Str255;
  3480.                                                             fieldAddr: Ptr;
  3481.                                                             fieldType: INTEGER)); OVERRIDE;
  3482.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3483.                 fields. }
  3484.  
  3485.                 END;
  3486.  
  3487. {--------------------------------------------------------------------------------------------------}
  3488.             TSaveDocCommand     = OBJECT (TNoChangesCommand) { Tells the document to save. }
  3489.                 PROCEDURE TSaveDocCommand.ISaveDocCommand(itsCmdNumber: CmdNumber;
  3490.                                                           itsDocument: TDocument);
  3491.                 { Initialize the SaveDocCommand procedurally. }
  3492.  
  3493.                 PROCEDURE TSaveDocCommand.DoIt; OVERRIDE;
  3494.                 { tell the document to save. }
  3495.  
  3496.                 PROCEDURE TSaveDocCommand.Fields(PROCEDURE
  3497.                                                  DoToField(fieldName: Str255;
  3498.                                                            fieldAddr: Ptr;
  3499.                                                            fieldType: INTEGER)); OVERRIDE;
  3500.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3501.                 fields. }
  3502.  
  3503.                 END;
  3504.  
  3505. {--------------------------------------------------------------------------------------------------}
  3506.             TRevertDocCommand    = OBJECT (TNoChangesCommand) { Tells the document to revert after
  3507.                                                               checking with the user }
  3508.                 PROCEDURE TRevertDocCommand.IRevertDocCommand(itsCmdNumber: CmdNumber;
  3509.                                                               itsDocument: TDocument);
  3510.                 { Initialize the RevertDocCommand procedurally. }
  3511.  
  3512.                 PROCEDURE TRevertDocCommand.DoIt; OVERRIDE;
  3513.                 { tell the document to revert if the user says OK. }
  3514.  
  3515.                 PROCEDURE TRevertDocCommand.Fields(PROCEDURE
  3516.                                                    DoToField(fieldName: Str255;
  3517.                                                              fieldAddr: Ptr;
  3518.                                                              fieldType: INTEGER)); OVERRIDE;
  3519.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3520.                 fields. }
  3521.  
  3522.                 END;
  3523.  
  3524. {--------------------------------------------------------------------------------------------------}
  3525.             TCommandList        = OBJECT (TSortedList)    { A list for keeping TCommands ordered by
  3526.                                                          priority }
  3527.                 PROCEDURE TCommandList.ICommandList;
  3528.                 { Initialize the CommandList procedurally. }
  3529.  
  3530.                 FUNCTION TCommandList.Compare(item1, item2: TObject): INTEGER; OVERRIDE;
  3531.                 { Compares Two TCommands based on their priority }
  3532.  
  3533.                 PROCEDURE TCommandList.Insert(item: TObject); OVERRIDE;
  3534.                 { Overridden to guarantee insertion even in low memory and to preserve arrival
  3535.                 sequence within "Compare" ordering. }
  3536.  
  3537.                 PROCEDURE TCommandList.Fields(PROCEDURE
  3538.                                               DoToField(fieldName: Str255;
  3539.                                                         fieldAddr: Ptr;
  3540.                                                         fieldType: INTEGER)); OVERRIDE;
  3541.                 { Used by the Inspector and the Debugger to display the contents of this class's
  3542.                 fields. }
  3543.  
  3544.                 END;
  3545.  
  3546. {--------------------------------------------------------------------------------------------------}
  3547.  
  3548.         VAR
  3549.             gAlwaysTrackCursor: BOOLEAN;                { set this to TRUE when you want the
  3550.                                                          application to track the cursor even if it
  3551.                                                          doesn't stray outside gCursorRgn. }
  3552.             gAppDone:            BOOLEAN;                { set this to TRUE when you want the
  3553.                                                          application to terminate }
  3554.             gApplicationStyle:    TextStyle;                { Application's default text style }
  3555.             {$Push} {$J+}
  3556.             gApplication:        TApplication;            { the application object }
  3557.             {$Pop}
  3558.  
  3559.             {$IFC qDebug}
  3560.             gAssumeFocused:     BOOLEAN;                { Actually do TView.AssumeFocused checking?
  3561.                                                          }
  3562.             gBusyTempRgn:        BOOLEAN;                { Is gTempRgn in use? }
  3563.             {$ENDC}
  3564.             gChooserOK:         BOOLEAN;                { if FALSE, user will not be allowed to
  3565.                                                          change the printer selection using 'Choose
  3566.                                                          Printer' DA while the application is
  3567.                                                          alive; if TRUE (the default set in
  3568.                                                          InitUMacApp), then printer-change will
  3569.                                                          only be disabled during background
  3570.                                                          printing. If you want it FALSE in your
  3571.                                                          application, the right time to set it is
  3572.                                                          after calling InitUMacApp (where it is
  3573.                                                          initialized to TRUE) and before calling
  3574.                                                          InitPrinting (where, if it's found to be
  3575.                                                          FALSE, the low- memory location governing
  3576.                                                          is option is poked). In the MultiFinder™
  3577.                                                          world this is pretty questionable
  3578.                                                          behaviour, though. }
  3579.             gClickCount:        INTEGER;                { number of 'saved up' mouse clicks; handled
  3580.                                                          in TApplication.DispatchEvent, ObeyEvent &
  3581.                                                          ObeyMouseDown. If a mouseDown, the value
  3582.                                                          is that returned by the call to
  3583.                                                          TApplication.CountClicks. If a mouseUp,
  3584.                                                          the value is left alone. Otherwise, set to
  3585.                                                          0. Also set to 0 is the 2 clicks were in
  3586.                                                          different parts ofthe window. }
  3587.             gClipClaimed:        BOOLEAN;                { Used by PerformCommand & ClaimClipboard to
  3588.                                                          determine, if DoIt of a cut/copy cmd
  3589.                                                          fails, whether the Clipboard had already
  3590.                                                          been claimed by the new command or not }
  3591.             gClipOrphanage:     TView;                    { A view to represent the Clipboard when the
  3592.                                                          application can't }
  3593.  
  3594.             gClipUndoView:        TView;                    { The view previously installed in the
  3595.                                                          Clipboard }
  3596.  
  3597.             gClipView:            TView;                    { The view currently installed in the
  3598.                                                          Clipboard }
  3599.             gClipWindow:        TWindow;                { The window holding the Clipboard display }
  3600.             gClipWrittenToDeskScrap: BOOLEAN;            { True if the clipboard view has been
  3601.                                                          written to the desk scrap. }
  3602.             gCouldPrint:        BOOLEAN;                { whether Printer code is accessible to the
  3603.                                                          application }
  3604.             gCurrPrintHandler:    TPrintHandler;            { If printing, this is set to the print
  3605.                                                          handler. Nil if not printing. }
  3606.             {$IFC qDebug}
  3607.             gDebugPrinting:     BOOLEAN;                { simple toggle for debugging printing }
  3608.             {$ENDC}
  3609.             gDocList:            TList;                    { list of documents }
  3610.             gDrawingPictScrap:    BOOLEAN;                { TRUE if a view's Draw routine is being
  3611.                                                          called in order to create PICT data in the
  3612.                                                          Desk Scrap; your View.Draw can check this
  3613.                                                          routine, and insert PictComments as
  3614.                                                          appropriate if it wishes to have them in
  3615.                                                          the Picture in the Desk Scrap }
  3616.             gDrawingPictScrapView: TView;                { the view being currently drawn in the PICT
  3617.                                                          scrap ??? this stuff is a good candidate
  3618.                                                          for a small change to the view
  3619.                                                          architecture to more easily allow
  3620.                                                          providing alternate drawing environments }
  3621.             {$IFC qExperimentalAndUnsupported}
  3622.             gEnableDoubleBuffering:        BOOLEAN;        { TRUE to enable automatic double buffering
  3623.                                                         when drawing/scrolling views }
  3624.             {$EndC}
  3625.         
  3626.             gErrorParm3:        Str255;                 { This is used as the last argument to
  3627.                                                          ParamText in ErrorAlert, if ErrorAlert
  3628.                                                          displays one of the standard alerts. (This
  3629.                                                          string will replace ^3 in those alerts.)
  3630.                                                          ErrorAlert also sets this to '' when
  3631.                                                          called. You can use this to parameterize
  3632.                                                          the automatic alerts that MacApp displays.
  3633.                                                          For example, TDocument.ReadFromFile sets
  3634.                                                          this to the document name. }
  3635.             gEventLevel:        INTEGER;                { A count of the number of nested calls to
  3636.                                                          PollEvent. }
  3637.             {$IFC qDebug}
  3638.             gExperimenting:     BOOLEAN;                { simple toggle for enabling/disabling
  3639.                                                          experimental features }
  3640.             {$ENDC}
  3641.             gFakeWindow:        WindowRecord;            { In MacApp 2.0 and earlier, this was
  3642.                                                         initialized with OpenPort, or OpenCPort,
  3643.                                                         and by setting its ControlList to NIL.
  3644.                                                         This was NOT a real window, just a port.
  3645.                                                           In MacApp 2.0.1 and later, this is a
  3646.                                                         real window. It's ignored in routines that
  3647.                                                         iterate over the windowList. }
  3648.  
  3649.             gFileCount:         INTEGER;                { # files to open/print from finder; set in
  3650.                                                          Init2 }
  3651.             gFinderPrinting:    BOOLEAN;                { TRUE if the Finder started the App up just
  3652.                                                          for printing docs }
  3653.             gFocusedView:        TView;                    { the view that is currently focused }
  3654.             gFreeWindowList:    TList;                    { list of free-standing (documentless)
  3655.                                                          windows }
  3656.             gGotClipType:        BOOLEAN;                { True if we can paste the data in the
  3657.                                                          clipboard }
  3658.             gHeadCohandler:     TEvtHandler;            { head of linked list of global co-handlers
  3659.                                                          }
  3660.             gIdlePhase:         IdlePhase;                { The current idle phase }
  3661.             gInBackground:        BOOLEAN;                { True if app is currently in background }
  3662.             gInitialized:        BOOLEAN;                { Set to TRUE at the end of IApplication }
  3663.             {$IFC qDebug}
  3664.             gIntenseDebugging:    BOOLEAN;                { debugging toggle for intensive debugging }
  3665.             {$ENDC}
  3666.             gLastClickPart:     INTEGER;                { the list window part clicked in-used for
  3667.                                                          double click detection }
  3668.             gLastDeskAcc:        LONGINT;                { time of the most recent possible excursion
  3669.                                                          to a a Desk Accessory }
  3670.             gLastMsePt:         Point;                    { coordinates of mouse in last event passed
  3671.                                                          to TApplication.CountClicks }
  3672.             gLastUpTime:        LONGINT;                { time of last mouse up event passed to
  3673.                                                          TApplication.ObeyEvent }
  3674.             gLongOffset:        VPoint;                 { Used in focusing }
  3675.             gLowSpaceInterval:    LONGINT;                { If >= 0, the frequency (in Ticks) with
  3676.                                                          which MacApp displays a low space alert.
  3677.                                                          (Defaults to kLowSpaceInterval.) If < 0,
  3678.                                                          MacApp doesn't display an alert. }
  3679.             gMacAppAlertFilter: ProcPtr;                { the default filter proc. Will be
  3680.                                                          automatically set to point to
  3681.                                                          MacAppAlertFilter. Set this to nil in your
  3682.                                                          code if you don't want it or call it from
  3683.                                                          your own filter proc if you just want to
  3684.                                                          add behavior. Someday we will fix all this
  3685.                                                          to be Object based. }
  3686.             gInFilter:            BOOLEAN;                { Flag that is set when we are in the
  3687.                                                          MacAppAlertFilter, used to indicate if we
  3688.                                                          should re-enter MacApp to handle updates
  3689.                                                          or not }
  3690.             gInhibitNestedHandling: BOOLEAN;            { TRUE if Failure was executed and the
  3691.                                                          outer- most event loop has not been
  3692.                                                          reached or the ErrorAlert routing has not
  3693.                                                          yet shown the failure to the user. Also
  3694.                                                          may be set to TRUE to inhibit continued
  3695.                                                          operation of MacApp Activate/Update
  3696.                                                          handling and idling during MacAppAlerts. }
  3697.             gMainEventMask:     INTEGER;                { Event mask used in main event loop.
  3698.                                                          Initialized by InitUMacApp. }
  3699.             gMainFileType:        OSType;                 { principal file type opened/printed by
  3700.                                                          application; set in
  3701.                                                          TApplication.IApplication; by default,
  3702.                                                          TApplication.SFGetFilters returns a list
  3703.                                                          of just this }
  3704.             gMBarDisplayed:     INTEGER;                { menus that are read in and installed in
  3705.                                                          menu bar }
  3706.             gMBarHierarchical:    INTEGER;                { menus that pop up when a menu item is
  3707.                                                          choosen }
  3708.             gMBarNotDisplayed:    INTEGER;                { menus that are read in but not installed }
  3709.             gNewScrapStuff:     ScrapStuff;             { the current ScrapStuff record used in
  3710.                                                          tracking the scrap }
  3711.             gNextSpaceMsg:        LONGINT;                { time when next low space message should be
  3712.                                                          displayed }
  3713.             gNullPrintHandler:    TPrintHandler;            { handles printing-relating messages for
  3714.                                                          views which don't print }
  3715.             gNumUntitled:        INTEGER;                { The number to assign to the next Untitled
  3716.                                                          document (assuming that the app provides a
  3717.                                                          template for filling in the number. You
  3718.                                                          must change STR# resource with ID 0 /
  3719.                                                          index 3 to read (for example)
  3720.                                                          Untitled-<<<#>>>. }
  3721.             gNoChanges:         TCommand;                { Value to return when the handler doesn't
  3722.                                                          return a command. You can just use NIL
  3723.                                                          now. (Left in for compatibility (2.0) }
  3724.             gOldChooserFlag:    BOOLEAN;                { The state of the chooser alert flag when
  3725.                                                          the application started up. }
  3726.             gOldScrapStuff:     ScrapStuff;             { the last ScrapStuff record used in
  3727.                                                          tracking the scrap }
  3728.             gOrthogonal:        ARRAY [VHSelect] OF VHSelect; { An Orthogonal set of VHSelects.
  3729.                                                                gOrthogonal[v] = h and
  3730.                                                                gOrthogonal[h] = v }
  3731.             gPageOffset:        VPoint;                 { offset in view of page being printed }
  3732.             gPrefClipType:        ResType;
  3733.             gPrintHandler:        TPrintHandler;            { a global print-handler object for use in
  3734.                                                          some standard printing-related activities;
  3735.                                                          this is initialized to be just a reference
  3736.                                                          to gNullPrintHandler, but if you call
  3737.                                                          InitPrinting, that will install a
  3738.                                                          non-trivial print-handler here… }
  3739.             gPrinting:            BOOLEAN;                { true if currently Printing }
  3740.             {$IFC qDebug}
  3741.             gReportEvt:         BOOLEAN;                { debugging toggle for reporting events }
  3742.             gReportMenuChoices: BOOLEAN;                { debugging toggle for tracing cmds }
  3743.             gRsrcCheck:         INTEGER;                { debugging toggle for checking resource
  3744.                                                          usage }
  3745.             {$ENDC}
  3746.  
  3747.             gSaveFocusRec:        FocusRec;                { a place to save off the focus to speed up
  3748.                                                          scrolling}
  3749.  
  3750.             gSignatures:        ARRAY [1..kMaxSignatures] OF IDType; { Standard object signatures }
  3751.             gSignatureIds:        ARRAY [1..kMaxSignatures] OF ObjClassId; { corresponding standard
  3752.                                                                           object ClassIds }
  3753.             gSignatureCount:    INTEGER;                { count of standard signatures stored }
  3754.  
  3755.             gStdHysteresis:     Point;                    { standard hysteresis used in
  3756.                                                          TCommand.ICommand }
  3757.             gStdStaggerCount:    INTEGER;                { Used to stagger windows created from
  3758.                                                          templates }
  3759.             gStdWMoveBounds:    Rect;                    { standard boundsRect to pass to DragWindow
  3760.                                                          Toolbox routine }
  3761.             gStdWSizeRect:        Rect;                    { standard sizeRect to pass to GrowWindow
  3762.                                                          Toolbox routine }
  3763.             gStdWScreenRect:    Rect;                    { Used to force a window onto the screen. If
  3764.                                                          the window is not in the GrayRgn, then at
  3765.                                                          least one corner of the window must lie
  3766.                                                          within gStdWScreenRect. }
  3767.  
  3768.             gSysWindowActive:    BOOLEAN;                { TRUE if the front window is a system
  3769.                                                          window }
  3770.             gSystemStyle:        TextStyle;                { System's default text style }
  3771.             gTarget:            TEvtHandler;            { the TEvtHandler that gets the first chance
  3772.                                                          at DoCommand, DoSetupMenu, DoKeyCommand,
  3773.                                                          Idle; should never be NIL -- If you do not
  3774.                                                          want your own target set this to the
  3775.                                                          application object }
  3776.  
  3777.             gTempRgn:            RgnHandle;                { gTempRgn is a temporary RgnHandle created
  3778.                                                          in InitUMacApp. When debugging: before
  3779.                                                          using gTempRgn, call UseTempRgn and when
  3780.                                                          done call DoneWithTempRgn; this ensures
  3781.                                                          that 2 routines do not try to use gTempRgn
  3782.                                                          and the same time }
  3783.             {$IFC qDebug}
  3784.             gTraceIdle:         BOOLEAN;                { allow tracing through idle }
  3785.             {$ENDC}
  3786.             gUndoState:         BOOLEAN;                { are we in undo or redo }
  3787.             gUndoCmd:            CmdNumber;                {}
  3788.             {$IFC qDebug}
  3789.             gUsedBy:            Str255;                 { The routine using gTempRgn }
  3790.             {$ENDC}
  3791.             gVarClipPicSize:    BOOLEAN;                { if TRUE, Pictures in the Clipboard are
  3792.                                                          treated as variable size, depending on the
  3793.                                                          window size; if FALSE (default), then
  3794.                                                          pictures in the Clipboard are drawn and
  3795.                                                          pasted ??? actual size }
  3796.             {$IFC qDebug}
  3797.             gWasTrcEnable:        BOOLEAN;                { Used to store old tracing state across
  3798.                                                          idleBegin/idleEnd calls to Idle }
  3799.             {$ENDC}
  3800.             gWResSignature:     IDType;                 { Signature used by TView.WRes }
  3801.             gWResType:            Str255;                 { Type used by TView.WRes }
  3802.             gWorkPort:            GrafPtr;                { Pointer to a graf port that is created
  3803.                                                          during initialization }
  3804.  
  3805.             { Pascal doesn't have structured constants so… }
  3806.             gZeroRect:            Rect;                    { SetRect(gZeroRect, 0, 0, 0, 0); }
  3807.             gZeroPt:            Point;                    { SetPt(gZeroPt, 0, 0); }
  3808.             gZeroVPt:            VPoint;                 { SetVPt(gZeroVPt, 0, 0); }
  3809.             gZeroVRect:         VRect;                    { SetVRect(gZeroVRect, 0, 0, 0, 0); }
  3810.  
  3811.             { These are really private but, they're here in case access is needed. }
  3812.             pCopyright:         StringHandle;
  3813.             pETSPatch:            TrapPatch;                { patch for ExitToShell }
  3814.             pFi:                FailInfo;                { Outermost failure handler }
  3815.  
  3816. {--------------------------------------------------------------------------------------------------}
  3817.  
  3818.             { D E B U G G I N G }
  3819.  
  3820.             {$IFC qDebug}
  3821.  
  3822.         PROCEDURE DoneWithTempRgn;
  3823.         { Indicates that gTempRgn is no longer in use. Call this only if qDebug is true. }
  3824.  
  3825.         PROCEDURE EntDebugger(entering: BOOLEAN);
  3826.         { Call to enter the MacApp Debugger }
  3827.  
  3828.         PROCEDURE UseTempRgn(byWhom: Str255);
  3829.         { Call this when you are about to use gTempRgn and qDebug is true. Used with DoneWithTempRgn
  3830.         will prevent you from trying to use gTempRgn from two places at the same time. }
  3831.         {$ENDC qDebug}
  3832.  
  3833.         FUNCTION LookupSymbol(VAR sym: Str255): LONGINT;
  3834.         { Call to see if anyone knows a reference for the given symbol }
  3835.  
  3836.         PROCEDURE NotYetImplemented(where: Str255);
  3837.         { Signals the notYetImplemented failure which when caught puts up an alert saying
  3838.         "Not Yet Implemented" and in debug WriteLns where. }
  3839.  
  3840.         { W I N D O W S }
  3841.  
  3842.         FUNCTION FreeIfWMgrWindow(w: WindowPtr;
  3843.                                  dispose: BOOLEAN): WindowPtr;
  3844.         { Calls DisposeWindow if dispose is true, else calls CloseWindow. Does nothing if w
  3845.         is nil.
  3846.         Returns NIL for convenient assignment back to the reference passed in. }        { Preferred }
  3847.  
  3848.  
  3849.         PROCEDURE FreeWMgrWindow(w: WindowPtr;
  3850.                                  dispose: BOOLEAN);
  3851.         { Left in for compatibility (2.0) }
  3852.  
  3853.         FUNCTION GetWindowVariant(theWindow: WindowPtr): INTEGER;
  3854.  
  3855.         FUNCTION NewPaletteWindow(itsRsrcID: INTEGER;
  3856.                                   wantHScrollBar, wantVScrollBar: BOOLEAN;
  3857.                                   itsDocument: TDocument;
  3858.                                   itsMainView: TView;
  3859.                                   itsPaletteView: TView;
  3860.                                   sizePalette: INTEGER;
  3861.                                   whichWay: VHSelect): TWindow;
  3862.         { Utility for creating MacDraw-like windows with 1 non-scrolling palette along the left edge
  3863.         (whichWay = h), or a non-scrolling status area at the top of the window (whichWay = v), and
  3864.         a main view that may or may not scroll. Signals Failure if the window could not be created.
  3865.         }
  3866.  
  3867.         FUNCTION NewSimpleWindow(itsRsrcID: INTEGER;
  3868.                                  wantHScrollBar, wantVScrollBar: BOOLEAN;
  3869.                                  itsDocument: TDocument;
  3870.                                  itsView: TView): TWindow;
  3871.         { Utility for creating simple windows that contain 1 view and may or may not scroll. Signals
  3872.         Failure if the window could not be created. }
  3873.  
  3874.         FUNCTION NewTWindow(itsRsrcID: INTEGER;
  3875.                             itsDocument: TDocument): TWindow;
  3876.         { Utility for creating a window object. Used within NewPaletteWindow & NewSimpleWindow.
  3877.         SIgnals Failure if the window could not be created. }
  3878.  
  3879.         FUNCTION NewTemplateWindow(viewRsrcID: INTEGER;
  3880.                                    itsDocument: TDocument): TWindow;
  3881.         { Creates a window using a 'WIND' resource and a 'view' template. }
  3882.  
  3883.         FUNCTION ParseTitleTemplate(VAR itsTemplate: Str255;
  3884.                                     VAR preDocname, constTitle: INTEGER): BOOLEAN;
  3885.         { Used in TWindow.IWindow to parse the template for window titles. Returns TRUE if it changed
  3886.         the template. preDocname is start of document name in string; constChars is total #
  3887.         characters of window title that are constants. (These values are fixed regardless of the
  3888.         document name.) If preDocname is 0, then the entire title is constant. }
  3889.  
  3890.         FUNCTION SubstituteInTitle(VAR title: Str255;
  3891.                                    newStuff: Str255;
  3892.                                    preDocname, constTitle: INTEGER): BOOLEAN;
  3893.         { Substitutes newStuff into the template as parsed by ParseTitleTemplate; returns TRUE if a
  3894.         substitution was made. }
  3895.  
  3896.         { C L I P B O A R D }
  3897.  
  3898.         PROCEDURE CanPaste(aClipType: ResType);
  3899.         { Call this in your SetUpMenus code to register an ability to paste a particular type of
  3900.         Clipboard data }
  3901.  
  3902.         FUNCTION PutDeskScrapData(aResType: ResType;
  3903.                                   aDataHandle: Handle): OSerr;
  3904.         { Call this from your TCommand method 'WriteToDeskScrap' (for a Command which changes the
  3905.         Clipboard) to write out data to the actual Desk Scrap. The return code from the Scrap
  3906.         Manager is returned as the function value -- will be noErr unless something went wrong.
  3907.         This procedure leaves aDataHandle UNLOCKED. Rather than calling this, you can call the
  3908.         ToolBox routine PutScrap yourself }
  3909.  
  3910.         { E R R O R S }
  3911.  
  3912.         PROCEDURE ErrorAlert(err: OSerr;
  3913.                              message: LONGINT);
  3914.         { Displays an error alert box. The message displayed in the alert is constructed base upon
  3915.         err and message, as described in the "Failure Handling" section of the "Cookbook" chapter
  3916.         of the MacApp manual. }
  3917.  
  3918.         FUNCTION LookupErrString(value: INTEGER;
  3919.                                  resourceID: INTEGER;
  3920.                                  VAR str: Str255): BOOLEAN;
  3921.         { Looks up an error value in an 'errs' resource and returns TRUE if found. resourceID should
  3922.         be that of a MacApp errs resource; we do the lookup first in errAppTable+resourceID, which
  3923.         applications can use to override or extend the MacApp table. If the value is not found, str
  3924.         will be empty. }
  3925.  
  3926.         FUNCTION MacAppAlert(alertID: INTEGER;
  3927.                              filterProc: ProcPtr): INTEGER;
  3928.         { Does SetCursor(arrow) before calling Alert. }
  3929.  
  3930.         PROCEDURE StdAlert(alertID: INTEGER);
  3931.         { no filterProc, reply ignored }
  3932.  
  3933.         { V I E W    R E S O U R C E   U T I L I T I E S }
  3934.  
  3935.         PROCEDURE RegisterStdType(typeName: Str255;
  3936.                                   signature: IDType);
  3937.         { Associates the given class with a signature. }
  3938.  
  3939.         FUNCTION NewStdObject(signature: IDType): TObject;
  3940.         { Returns the prototype object for the given signature. }
  3941.  
  3942.         FUNCTION NewViewRsrc(VAR p: UNIV Ptr): ViewRsrcHndl;
  3943.         { Convenience routine to create a new view resource template handle. Passes back in "p" the
  3944.         pointer to the first template entry. }
  3945.  
  3946.         PROCEDURE DoneViewRsrc(viewRsrc: UNIV Handle;
  3947.                                lastPtr: UNIV LONGINT);
  3948.         { Cuts back the handle to the proper length, based on lastPtr which should be the address of
  3949.         the next template entry. }
  3950.  
  3951.         FUNCTION ExpandPtr(viewRsrc: UNIV Handle;
  3952.                            VAR p: UNIV LONGINT;
  3953.                            offset: LONGINT): Ptr;
  3954.         { Bumps size of view resource if necessary to add a new template. Amount to bump is set to at
  3955.         least kViewRsrcExpandAmt over the current size. "p" is offset to point to the next
  3956.         available position for a new template. Returns the old value of p before it was updated. }
  3957.  
  3958.         FUNCTION ExpandPtrWStr(viewRsrc: UNIV Handle;
  3959.                                VAR p: UNIV LONGINT;
  3960.                                offset, len: LONGINT): Ptr;
  3961.         { Bumps size of view resource if necessary to add a new template which ends with a
  3962.         variable length string, the length of which is passed in len.
  3963.         Returns the old value of p before it was updated. }
  3964.  
  3965.         PROCEDURE OffsetPtr(VAR p: UNIV LONGINT;
  3966.                             offset: LONGINT);
  3967.         { Adds offset to p, forcing word alignment.}
  3968.  
  3969.         PROCEDURE OffsetPtrWStr(VAR p: UNIV LONGINT;
  3970.                                 offset: LONGINT);
  3971.         { Adds offset to p, taking length of trailing variable length string into account, forcing
  3972.         word alignment.}
  3973.  
  3974.         { M I S C E L L A N E O U S }
  3975.  
  3976.         PROCEDURE ApplicationBeep;
  3977.         { If gApplication is not NIL just calls gApplication.Beep else it does a SysBeep.
  3978.         Removes a circular reference for UFailure.}
  3979.  
  3980.         FUNCTION CallAlertFilter(theDialog: DialogPtr;
  3981.                                  VAR theEvent: EventRecord;
  3982.                                  VAR itemHit: INTEGER;
  3983.                                  theAlertFilter: ProcPtr): BOOLEAN;
  3984.             INLINE $205F,                                { MOVE.L (A7)+,A0 }
  3985.                    $4E90;                                { JSR (A0) }
  3986.         { Lets you call the alert filter specified in theAlertFilter.  Useful for providing
  3987.         your own alert filter behaviour and then passing on to MacApp's }
  3988.  
  3989.         FUNCTION GetNewCenteredDialog(dialogID: INTEGER;
  3990.                                       dStorage: Ptr;
  3991.                                       behind: WindowPtr): DialogPtr;
  3992.         { The same as GetNewDialog except it centers the dialog on the screen and sets the cursor to
  3993.         an arrow. }
  3994.  
  3995.         PROCEDURE GetFocus(VAR theFocusRec: FocusRec);
  3996.         { gets the current focus into a focusrec. The focusrec.clipRgn must be a valid rgn useful for
  3997.         saving and restoring the focus behind MacApp's back.}
  3998.  
  3999.         PROCEDURE SetFocus(theFocusRec: FocusRec);
  4000.         { sets the current focus from a focus rec }
  4001.  
  4002.         PROCEDURE GetTextStyleFontInfo(theTextStyle: TextStyle; VAR theFontInfo: Fontinfo);
  4003.         { Returns the FontInfo record for the font/face/size specified in theTextStyle.  Uses
  4004.         a temporary port so you don't have to. }
  4005.  
  4006.         PROCEDURE ExitMacApp;
  4007.         { Call this if for some reason you want to immediately exit the application. It calls
  4008.         gApplication.Terminate, cleans up some other internal stuff, and then calls ExitToShell.
  4009.         (Normally, you would not call this, because MacApp takes care of terminating the
  4010.         application.)}
  4011.  
  4012.         PROCEDURE InitUMacApp(callsToMoreMasters: INTEGER);
  4013.         { Initialize the UMacApp unit call this in your program after calling: InitToolBox and
  4014.         ValidateConfiguration. }
  4015.  
  4016.         PROCEDURE InstallIfPrintHandler(aPrintHandler: TPrintHandler; aView: TView);
  4017.         { Install a clone of aPrintHandler into the view if aPrintHandler is not the
  4018.         same as the null print handler. (Typically if printing is initialized.)  This
  4019.         lets us install a print handler if printing is being used in the application
  4020.         and do NOTHING if it is not. }
  4021.  
  4022.         FUNCTION MacAppAlertFilter(theDialog: DialogPtr;
  4023.                                    VAR theEvent: EventRecord;
  4024.                                    VAR itemHit: INTEGER): BOOLEAN;
  4025.         { Default alert filter used throughout MacApp.    Lets you answer yes and no to dialogs with
  4026.         keystrokes. Handles "cmd-." and escape. If the alert has not been called in a failure sequence
  4027.         then the application also handles update and activate events and idles. }
  4028.  
  4029.         FUNCTION MakeNewRgn: RgnHandle;
  4030.         { Calls NewRgn, then FailNIL}
  4031.  
  4032.         FUNCTION RectIsVisible(r: Rect): BOOLEAN;
  4033.         { Determine if a rect is visible in the current grafport. }
  4034.  
  4035.         PROCEDURE SetHLPenState(fromHL, toHL: HLState);
  4036.         { Set the pen state for highlighting by XOR, given the highlight transition. You can use this
  4037.         if you use Paint<X> or Frame<X> or line drawing for your highlighting. }
  4038.         { ??? Add a pattern parameter or make a helper routine that has a pattern parameter ??? }
  4039.  
  4040.         PROCEDURE FinderSegProc;
  4041.         { This is a dummy procedure to allow us to find the Finder segment }
  4042.  
  4043.         PROCEDURE CleanupMacApp;
  4044.         { Called as the final step of TApplication.Run }
  4045.         {$ENDC}
  4046.  
  4047.         PROCEDURE VisibleRect(VAR r: Rect);
  4048.         { Get the currently visible rectangle as defined by thePort clip region }
  4049.         {$IFC NOT UsingIncludes}
  4050. END.
  4051. {$ENDC}
  4052.